// Collection of code snippets by Arne VajhÃ¸j 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package test.server;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.RMISocketFactory; 
import java.rmi.registry.LocateRegistry;

// server hoved program
public class MyServerMain {
   public static void main(String[] args) {
      try {
         // enable security
         System.setSecurityManager(new RMISecurityManager());
         // sæt socket factory
         RMISocketFactory.setSocketFactory(new FixedPortRMISocketFactory());
         // start registry
         LocateRegistry.createRegistry(60000);
         // bind server objekt
         Naming.rebind("rmi://localhost:60000/MyServer", new MyServerImpl());
      } catch (RemoteException e) {
         e.printStackTrace();
      } catch (MalformedURLException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}
