import java.rmi.Naming;
import java.rmi.RemoteException;


/**
 * @author bon
 *
 */
public class RMI_first_demo_Client {
	
    public RMI_first_demo_Client(String msg, String host_ip)
    {
    	try {
    		RMI_first_demo_Interface service = (RMI_first_demo_Interface)Naming.lookup("rmi://" + host_ip + "/RMI_first_demo");
    		service.greeting(msg);
    	} catch (Exception e) {
    		System.out.println("RMI_first_demo Naming lookup fails!");
			System.out.println(e);
    	}
    }


	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		// Check for hostname argument
		if (args.length != 2)
		{
			System.out.println
			("Syntax - java RMI_BioAPP_AsteriskJava_Client <host_IP> <Service_UID> <srcFileName_to_be_sent_over> <socket_ip> <socket_port> <remote_fileName>");
			System.exit(1);
		}

		// Assign security manager
//		if (System.getSecurityManager() == null)
//		{
//			System.setSecurityManager
//			(new RMISecurityManager());
//		}

		// Call registry for Service
		new RMI_first_demo_Client(args[0], args[1]);		
	}

}

