Spy on a Java program

While a Java program is running in a console window, you can can get a stack dump of the program at any time, while it is running. This is very useful for debugging, especially for heavily multithreaded programs.

Under Windows, just type control-break in the console of a running Java program.

Under Linux or Unix, send a QUIT signal to the java process. You might be able to do this simply by typing control-backslash in the terminal window. If not, you need to find out the process ID of the program using ps. Then send a QUIT signal to it with

kill -QUIT java process pid

This causes the program to output a stack dump of all running threads. This is an excellent way to find out quickly what’s going on in your program.

Share This | Comments | Permalink | Trackback | Comments feed

One response

  • Trackback | Java Programming | | 24 May 2007
    [...] While a Java program is running in a console window, you can can get a stack dump of the program at any time, while it is running. This is very [...]

Post a comment

(required)
(required)
Close
E-mail It