Thread dump is essential for Java application troubleshooting. If you are working on performance related, memory leakage, debugging, etc. then you will often be asked to take thread and heap dump.

You may take the dump manually but if you would like to do it automatically then here is how you can do it.The following demonstration is based on

The following demonstration is based on WebSphere 9, but the procedure would be similar to other WAS version.

Taking Thread Dump When JVM Stop

There might be a scenario where you would like to take the thread dump whenever JVM stop. This will be useful when you are not sure whom or how JVM is getting stopped.

To configure this;

  • Login to WebSphere Administrative Console
  • Navigate to Servers >> Server Types >> WebSphere application servers
  • Go inside the JVM and expand “Java and Process Management” under Server Infrastructure
  • Click Process definition
  • Click “Java Virtual Machine” under Additional Properties >> Custom properties
  • Click New and enter Name as
  • Value as true 
  • Click OK


  • Review and Save the configuration

Now, heap dump will be generated whenever JVM stop.

I stopped the JVM and could see the following javacore file on WAS server under profile path.

-rw-r--r--. 1 root root 3179348 Nov 28 22:49 javacore.20161128.224916.4926.0001.txt
-rw-r--r--. 1 root root 3124208 Nov 28 22:49 javacore.20161128.224924.4926.0002.txt

Taking Thread Dump When Hung

If you are having hung thread issue, and currently you take the dump manually, then you can automate this.

By doing basic configuration, WebSphere will generate the dump whenever a thread is hung for configured timed.

  • Login to WAS Console and go inside respective JVM
  • Expand “Administration” under Server Infrastructure and click Custom Properties
  • Add the following three properties – Generate dump when a thread is hung for configured time. Value is in seconds. – How frequently thread monitor should check for the hung threads. The value in seconds. – Generate dump when detected. Value is true.


Above configuration will generate dump whenever a thread is hung for 600 seconds, and WebSphere will monitor the thread every 300 seconds.

Once you have the dump, you can analyze and fix the application issue. I hope this helps.