LocateRegistry.getRegistry(1099).list();
System.out.println("rmiregistry WAS started before running the application"); }
That message is misleading. getRegistry()
doesn't perform any network communication, so the fact that it succeeded isn't a valid indication that the Registry is running. Only using the result of getRegistry()
can tell you that.
You're doing this back to front. You must try the createRegistry()
call first, and if that fails do the getRegistry() call.
createRegistry()` will fail if the Registry is already running, and succeed if it isn't.