If so, how can I find out which of the processes (of all others in the system) and how to kill it so that its shutdownhook is executed?
The reason I want to do this is because I want to implement something like apache start, apache stop, after which after starting apache start or apache the server process stops or stops in the background and I get a command or prompt bash back; this should work with both linux and windows.
It is possible, but it will be a specific operating system. There is nothing in the JVM that automatically gives you access to destroy other virtual machines.
kill ( ), .
kill
, unix- , script, , , ProcessBuilder .
ProcessBuilder
U , , .
, u , jvm. jvm, , . , , :
, u
, JMX.
JMX- Java- API, .
With JMX, you do not need to implement anything socket and resolution. You just need to provide a function called remote using JMX. You can also specify the user and password for access.