/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package calculatriceclient;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import org.firstejbmodule.calculatrice.CalculatriceBeanRemote;

/**
 *
 * @author Hoss
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        InitialContext ctx;
        try {
            Properties props = new Properties();
            props.load(new FileInputStream("C:\\Users\\ausu\\Documents\\NetBeansProjects\\CalculatriceClient\\src\\java\\calculatriceclient\\jndi.properties"));
            ctx = new InitialContext(props);
            Object ref = ctx.lookup("java:global/FirstEJBModule/CalculatriceBean!org.firstejbmodule.calculatrice.CalculatriceBeanRemote");
            CalculatriceBeanRemote calc
                    = (CalculatriceBeanRemote) PortableRemoteObject.narrow(ref, CalculatriceBeanRemote.class);
            int x = 1;
            int y = 2;
            int expResult = calc.Add(x, y);
            System.out.println(expResult);
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
    }

}
