If so, how can I find out which process is it(out of all the others on the system) and how do I kill it such that its shutdownhook gets executed?
Reason I want to do this is because I want to implement something like apache start, apache stop whereby after invoking apache start or apache stop, a server process starts or stops in the background and I get the command or bash prompt back; this is suppose to work on both linux and windows.
It's possible, but it will be operating system specific. There's nothing in the JVM that automatically gives you access to kill other VMs.
You'll either need to call your operating system's kill
command (or equivalent) or write some native code.
It can be done, and if you're only going to run on unix-like systems, then your best option would be to write a shell script that does what you want, and then execute it with ProcessBuilder
and friends.
U can think about opening a service on servant side ,which is for close itself, to be handled by the master application.
On the other hand, if u do not want to do it, u need to find a way to get the processes of a jvm instance. If u just want to kill jvm, it would be easy but for a specific process. U need some help I think, like this:
link
Hope it works for u
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With