Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM thread dump location

Tags:

java

jvm

When I issue a kill -3 <pid> command to my Java program, it generates the thread dump on the console. How do I redirect this to a file?

like image 492
user242591 Avatar asked Jan 14 '10 06:01

user242591


3 Answers

Two options:

Run your Java application with stdout redirected

java com.example.MyApp > out.txt

Use jstack instead.

The jstack utility allows you to get a thread dump and send the output to the current console instead of the stdout of the Java application, allowing you to redirect it.

For example, if the PID of your Java application is 12345 (use the jps utility to find it quickly):

jstack 12345 > threads.txt
like image 52
ZoogieZork Avatar answered Oct 13 '22 20:10

ZoogieZork


I usually use the NetBeans profiler, but jvisualvm is available from the command line.

like image 34
trashgod Avatar answered Oct 13 '22 21:10

trashgod


If you want details of all threads and other JVM details, try jconsole.

like image 41
Shane Avatar answered Oct 13 '22 20:10

Shane