Java - Diagnosis Stuck Running JVM
Here is some commands for diagnosis a stuck or no responsive Java process, JVM.
First of all get the PID of the Java process:
$ ps ux | grep java
Sending the Unix signal #3, QUIT
, to terminate the process:
$ kill -3 PID
In the cas of a Java process, the JVM exits and dumps thread information. For other Unix process, it dumps core (memory snapshot).
The thread dump lists all thread within the following information:
- The name of the thread
- The priority thread
- The thread identifier (ID)
- The current threat status or state (NNABLE, WAITING, BLOCKED)
- The call stack of the thread
Another option, without terminating the Java process is to use the jcmd
command (available since Java 8). The command sends a diagnostic request to the JVM .
Generating thread dump: jcmd PID Thread.print
The jcmd
command can return many more information than thread on the JVM. The complete list is available in the documentation. For example, you can obtain: uptime, the executing command line, system properties, JVM version, heap dump, GC, …