/* This is the server providing methods to be called remotely via RMI. * It must provide the methods. * It must create an instance of the server and put it in the rmiregistry * under the agreed name "HelloServer". */ import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class HelloImpl extends UnicastRemoteObject implements Hello { private String name; // Constructor public HelloImpl(String s) throws RemoteException { super(); name = s; } // This is the one method of this interface that can be called remotely public String sayHello() throws RemoteException { return "Hello " + name ; } public static void main(String args[]) { // Create and install a security manager System.setSecurityManager(new RMISecurityManager()); try { // create an instance of the server HelloImpl obj = new HelloImpl("from Nancy's HelloServer"); // Put it into the naming registry server Naming.rebind("//carver.npac.syr.edu/HelloServer", obj); System.out.println("HelloServer bound in registry"); } catch (Exception e) { System.out.println("HelloImpl err: " + e.getMessage()); e.printStackTrace(); } } }