String server = "localhost";
if (args.length < 1) {
System.out.println ("Usage: java Client <rmihost>");
System.exit(1);
} else {
server = args[0];
}
// Set a security manager so that the client can
// download the activatable object's stub
//
System.setSecurityManager(new RMISecurityManager());
try {
String location = "rmi://" + server + "/MyClass";
AnotherRemoteInterface ari =
(AnotherRemoteInterface)Naming.lookup(location);
System.out.println("Got a remote reference to the class " +
"MyClass");
// "result" will be appended to by the remote method call
//
String result = "Watson are you there? ";
result = (String)ari.calltheServer(result);
System.out.println("Called the remote method");
System.out.println("Result: " + result);
} catch (Exception e) {
System.out.println("Exception: " + e);
e.printStackTrace();
}