Is it possible for a java process in one jvm to kill / stop another java process in another jvm?

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.

+5
source share
3 answers

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 ( ), .

, unix- , script, , , ProcessBuilder .

+4

U , , .

, u , jvm. jvm, , . , , :

, u

+2

, 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.

0
source

All Articles