How to get java thread stack traces for a Windows service with jstack

Categories Development, Java

When running in a console window, pressing CTRL+Break signals the JVM to print out all stack traces of currently running threads.

If your application runs as a service (or linux/unix dæmon) you can’t press CTRL+Break, so you have to signal the JVM yourself to produce the stack trace. You can do that on linux by signaling a QUIT to the process, or by using jstack and the PID.
Good news, Java SE 6 on Windows comes with jstack. Yupee! ;).

So next time you need a thread dump from a java application running as a service just get the pid, fire up a cmd and run jstack <pid>.

2 thoughts on “How to get java thread stack traces for a Windows service with jstack

  1. Hello,
    My computer worked not correctly, too much errors. Please, help me to fix buggs on my computer.
    My operation system is Windows XP.
    Thx,
    uttetlycliela

Leave a Reply

Your email address will not be published. Required fields are marked *