public class HelloImpl extends UnicastRemoteObject
implements Hello {
public HelloImpl() throws RemoteException { }
private String severalHellos() { String hellos = ""; for (int i = (int) (5*Math.random()); i >= 0; i--) hellos += "Hello "; return hellos; } public String sayHello() { return severalHellos() + "RMI world already!"; }public static void main(String args[]) {try {
HelloImpl obj = new HelloImpl();
// Bind this object instance to the name "HelloServer"
Naming.rebind("HelloServer", obj);
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}