// Copyright © 1998 Sun Microsystems, Inc. All Rights Reserved. // package examples.activation; import java.rmi.*; public class Client { public static void main(String args[]) { String server = "localhost"; if (args.length < 1) { System.out.println ("Usage: java Client "); System.exit(1); } else { server = args[0]; } try { String location = "rmi://" + server + "/ActivatableImplementation"; // Since you can't create an instance of an interface, what we get // back from the lookup method is a remote reference to an object // that implements MyRemoteInterface. // // Then we cast the remote reference (serialized stub instance) // returned from Naming.lookup to a "MyRemoteInterface" so we can // call the interface method(s). // MyRemoteInterface mri = (MyRemoteInterface)Naming.lookup(location); System.out.println("Got a remote reference to the object that" + " extends Activatable."); // The String "result" will be changed to "Success" by the remote // method call // String result = "failure"; System.out.println("Making remote call to the server"); result = (String)mri.callMeRemotely(); System.out.println("Returned from remote call"); System.out.println("Result: " + result); } catch (Exception e) { e.printStackTrace(); } } }