To install on Ubuntu, you must install the Java Development Kit (JDK)
. While the Java Runtime Environment (JRE) allows you to run Java apps, it does not include diagnostic tools like Stack Overflow 1. Check if jstack is already installed Run the following command to see if is available on your path: jstack -version Use code with caution. Copied to clipboard
If you get a "command not found" error, you need to install the JDK. perifery.atlassian.net 2. Install the JDK via apt The easiest way is to install the default-jdk
package, which provides the recommended version for your Ubuntu release. Update your package list: sudo apt update Use code with caution. Copied to clipboard Install the JDK: sudo apt install default-jdk Use code with caution. Copied to clipboard Alternatively, for a specific version like OpenJDK 11: sudo apt install openjdk-11-jdk Ask Ubuntu 3. Verify the installation After installation, confirm that is now accessible: which jstack Use code with caution. Copied to clipboard This should return a path like /usr/bin/jstack TheServerSide How to use jstack Once installed, you can generate a thread dump for a running Java process by finding its Process ID (PID) and running: jstack
To install on Ubuntu, you must install a full Java Development Kit (JDK) rather than just a Runtime Environment (JRE), as
is a serviceability tool included only in the JDK's binary folder. How to Install via Terminal The most efficient way to get
is to install the default OpenJDK package provided by Ubuntu's repositories. Update your package list sudo apt update Use code with caution. Copied to clipboard Install the Default JDK This package includes the Java compiler ( ) and diagnostic tools like sudo apt install default-jdk Use code with caution. Copied to clipboard Verify the installation Check if the command is now available in your path. Use code with caution. Copied to clipboard To install on Ubuntu, you must install the
is a vital diagnostic tool that prints Java thread stack traces for a given process. It is primarily used for: jstack - Oracle Help Center
Restart your terminal or run source /etc/environment to apply the changes. Then, verify that jstack is installed correctly:
jstack -version
This should output the version of jstack. Step 5: Verify jstack Installation Restart your terminal
bin directory is not in your PATH. Run export PATH=$PATH:/usr/lib/jvm/java-17-openjdk-amd64/bin temporarily, or add it to ~/.bashrc.If you’re a Java developer or a system administrator troubleshooting a production Java application on Ubuntu, you’ve likely encountered the need to inspect thread stacks, detect deadlocks, or analyze high CPU usage. The go-to tool for this task is jstack. However, unlike apt packages like vim or curl, jstack doesn’t come as a standalone package. This guide will walk you through everything you need to know about installing jstack on Ubuntu, verifying your setup, and using it effectively.
Verify that the JDK is installed correctly:
java -version
This should output the version of Java installed on your system.
sudo apt install openjdk-8-jdk
After installation, verify that jstack is now accessible:
jstack -version
Example output:
1.8.0_392