sudo tar -xzf jdk-17_linux-x64_bin.tar.gz -C /opt/
This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.
jstack is a command-line utility that prints Java stack traces of running Java processes. It's an essential tool for debugging thread deadlocks, analyzing high CPU usage, and troubleshooting performance issues in Java applications.
Installing JDK and taking a jstack threads dump or stack dump install jstack on ubuntu
: Confirm the tool is available in your path. jstack -help How to Use jstack
If your project requires a specific Java version, install it directly: sudo apt install openjdk-21-jdk -y Use code with caution. OpenJDK 17: sudo apt install openjdk-17-jdk -y Use code with caution. OpenJDK 11: sudo apt install openjdk-11-jdk -y Use code with caution. Step 4: Verify the Installation
The output will be similar to the java -version command. sudo tar -xzf jdk-17_linux-x64_bin
If jstack hangs or fails to attach, the process may be unresponsive.
If your Java process is running as the tomcat or www-data user, you must run jstack as that user using sudo : sudo -u tomcat jstack 12345 > thread_dump.txt Use code with caution.
: Send a QUIT signal to generate a thread dump in the process’s standard output Can’t copy the link right now
source ~/.bashrc
for i in 1..5; do jstack -l 12345 > thread_dump_$(date +%H%M%S).txt sleep 5 done
This will print the entire stack trace of all threads directly to your terminal.