/Users/lyon/j4p/src/net/rmi/simpleExample/RmiHelloServer.java

1    package net.rmi.simpleExample; 
2    import java.rmi.Naming; 
3    import java.rmi.RemoteException; 
4    public class RmiHelloServer { 
5        // before you run this program, 
6        // you must start the rmiregistry 
7        // from the classpath root. 
8        public static void main(String args[]){ 
9            try { 
10               startServer(); 
11           } catch (RemoteException e) { 
12               e.printStackTrace(); 
13           } catch (java.net.MalformedURLException e) { 
14               e.printStackTrace(); 
15           } 
16       } 
17    
18       private static void startServer() 
19               throws RemoteException, 
20               java.net.MalformedURLException { 
21           println("starting server"); 
22           RemoteHello ro = new RemoteHelloImplementation(); 
23           println("binding remote instances"); 
24           Naming.rebind("RemoteHello",ro); 
25           println("waiting for invocations"); 
26       } 
27    
28       public static void println(Object o){ 
29           System.out.println(o); 
30       } 
31   } 
32