Search code examples
javaipcrmiinterprocess

is it a good idea to exec start rmiregistry in RMI server?


is it a good idea to put Runtime.getRuntime().exec("start rmiregistry"); in RMI server to automatically start the rmiregistry? Or you guys got other suggestion?


Solution

  • You might want to try something like this:

      try {
             java.rmi.registry.LocateRegistry.createRegistry(1099);
             System.out.println("RMI registry ready.");
          } catch (Exception e) {
             System.out.println("Exception starting RMI registry:");
             e.printStackTrace();
          } 
    

    Taken from here. Documentation available here.