I don't think there is a way. Neither LocateRegistry nor Registry provide a destroy or unload method of some sort.
Of course the registry will be gone when the JVM it runs in (in the case you started it from code that's the JVM your application runs in) terminates.
Joined: Jun 25, 2004
Gosh. My server GUI has 2 buttons. One of them is the start RMI service button, while the other is the halt RMI service button. Now I guess I have to think of other workarounds for the halt button.
Thanks for your input.
Joined: Oct 12, 2000
you can use registry.unbind(String) to remove a service from the running registry. Or alternatively define a NullObject implementing the same interface as your real service and rebind to that. That way the client could still call the service without getting exceptions and the remote dummy service could then give nothing back on every read request and ignore all updates (maybe handing a message that the service is unavailable instead as a statuscode).