How to Obtain a Thread Dump (Stack Traces) from a Java Process or Core File of a Java Process on Windows
Applies To
Java SE JDK and JRE - Version 6 and later
Introduction
On Windows, there are multiple ways to obtain a Thread Dump (a Stack Trace for each thread) from a Java process, or from a core file of a Java process.
| Tool | Works on a Process? | Works on a core file? | Java Frames?* | Native Frames?** |
|---|---|---|---|---|
| jstack | yes | no | yes | no |
| Ctrl + Break | yes | no | yes | no |
| jconsole | yes | no | yes | no |
| jvisualm | yes | no | yes | no |
| WinDbg | yes | yes | no | yes |
*‘Java Frames’ means that the tool is able to print a Java method name
on the stack.
**‘Native Frames’ means that the tool is able to print symbolic or
clear text name of a native function on the stack.
jstack
On Windows, jstack has been available since JDK 6. It is not available
in the JRE. jstack prints the stack traces of all Java threads for a
given Java process.
jstack [option] <PID>
For more information on jstack, see the jstack
Documentation
Note: jstack on Windows does not support printing the mixed mode
(both Java and native C/C++ frames) stack trace.
Ctrl+Break
On Windows, the combination of pressing the Ctrl key and the Break key at the application console (standard input) causes the HotSpot VM to print a thread dump to the application’s standard output.
JConsole
On Windows, JConsole has been available since JDK 5. It is not available in the JRE. Note that it is called JConsole, Java Console is something different. JConsole provides a graphical user interface and its purpose is to monitor a running Java process.
In order to obtain a stack trace, connect JConsole to the process and click on the Threads Tab. The Threads list in the lower left corner lists all the active threads. Click on the name of a thread in the Threads list to display the stack trace about that thread to the right.
See also:
Java VisualVM (jvisualvm)
Java VisualVM was first bundled with the Java SE in JDK 6u7. It is not available in the JRE. Similarly to JConsole, Java VisualVM provides a graphical user interface.
In order to obtain a stack trace, connect Java VisualVM to the process and click on the Threads Tab. The Threads list lists all the active threads. Click on the Thread Dump Button in order to obtain a thread dump.
See also:
WinDbg
WinDbg is a multi-purpose debugger for Microsoft Windows, distributed on
the web by Microsoft. The WinDbg command that gives the stack trace of
all native threads is ~* k.
See also Microsoft’s Documentation.
Note: The WinDbg utility is from Microsoft and it is not supported by Oracle. The WinDbg utility is from Microsoft and it is not supported by Oracle.
Last reviewed on Sat Feb 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)