Using JStack to get thread dump

There are many ways of getting thread dump of any Java process. JDK itself ships with JVisualVm which has a feature of triggering the thread dump. But it also has a simpler way of doing the same without opening the VisualVm application.

The JDK ships with a tool named jstack for generating thread dumps.

Running it is simple :

c:/java/bin/jstack.exe PID

Where PID is the process ID of the process whose thread dump you are interested in. You can use task manager to find out the PID of your java process.

If you want to save the thread dump in some file, use this command :

c:/java/bin/jstack.exe PID >c:/downloads.dump.txt

You might get ‘Access is denied’ error. Try to open command prompt as administrator