0

May be this question is too simple, but I am unable to find a solution anywhere.

I am running a webapp in Tomcat on JVM. I need to stop the JVM by invoking Control-Break. I need to do it from within the Java code. I don't know how to do it.

Can you please help me here? Thanks in advance!

kajarigd
  • 1,299
  • 3
  • 28
  • 46

1 Answers1

0

you can always launch another process to do it for you, for example:

Runtime.getRuntime().exec("kill -QUIT <pid>");
Guy Gavriely
  • 11,228
  • 6
  • 27
  • 42
  • updated, changed to -QUIT, I think SIGINT is CTRL-C and QUIT is CTRL_BREAK, in any case you can use kill command to send those signals – Guy Gavriely Nov 27 '13 at 06:50
  • to get the pid see http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id – Guy Gavriely Nov 27 '13 at 06:58
  • I ran the command, got the following exception: Executing kill -QUIT 7248 java.io.IOException: Cannot run program "kill": CreateProcess error=2, The system cannot find the file specified – kajarigd Nov 27 '13 at 07:21