Spy on a Java program

Tuesday, 25 November 2003

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.

Tags: ,


You can leave a comment, or trackback from your own site.

  1. Java Spy program

Leave a comment