import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; class HelloImpl implements Hello { public String sayHello() throws RemoteException { System.out.println("Remote Invokation of method sayHello()"); return "Hello World!"; } } public class HelloServer { public static void main(String args[]) { try { String name = "Hello"; Hello hello = new HelloImpl(); Hello stub = (Hello) UnicastRemoteObject.exportObject(hello, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); } catch (Exception e) { System.out.println("HelloServer Exception: " + e.getMessage()); e.printStackTrace(); } } }