To start the rmiregistry programmatically:
LocateRegistry.createRegistry(1099);To stop it programmatically:
UnicastRemoteObject.unexportObject(registry, true);However, you can also do it "dirty" (I tried this successfully):
Runtime.getRuntime().exec(rmiRegistry);// rmiRegistry is e.g. ".../rmireghistry.exe"
The benefit of the last method is that "rmiregistry" is its own process which you can monitor (e.g. TaskManager in Windows) and kill seperatly if necessary during debugging.