If you're using RMI already, why not just make a remote method called "shutdown()" or something to de-register from the rmiregistry and call System.exit()?
This is actually a lot easier to do than kill the process. To kill a process you have to code special ways on every platform you want to run on. Another problem is finding the exact process to kill - most JVMs name *every* java process running "java" - you have to run something internal to the program you want to kill to get the process id. This requires interacting with native code (again for each platform you want it to run on).
Another nice point to using a remote method to do this is that you can do a 'nice' shutdown and wait for all remote connections to close before actually shutting down. If you kill the process, it just shuts down right then, no matter what else is going on.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Originally posted by amit bathla: u can kill a process using (kill pid) command in linux or unix but for this u have to know the pid of ur process this will be different every time u call ur prog. in windows who knows ???
The Windows equivalent is "taskkill /pid processID".