How can I programmatically stop a RMI server?
RMI Servers start a thread that never ends. This is so that the Server is persistent until manually shut down.
However, you can provide a remote method, shutDown(), for the Remote Server.
When the Server finishes all clean-up processing it wakes up the shutdown thread.
The shutdown thread, after a two (2) second delay, calls System.exit(0) to end the Java Virtual Machine. The delay is so that messages from the Server to the initiating Client complete the journey.