Oracle (sun) jdk console tools.

Modern oracle JVMs (java 1.7, java 1.6) are bundled with diagnostic tools of your jvm during run-time. Here i'm going introduce the most prominent of them.

First to mention is of course VisualVM which evolves even independently of jvm releases. VisualVM allows relative deep analysis and its comprehensive enough furthermore it's open source tool.

However it reaches limits when you have to work with java version prior to 1.5. (in a real world sometimes thing changes slowly ;) Also it's often the case that it's not easy to connect over RMI remotely to productive machines, therefore its never a bad thing to be familiar with console tools modern jdk and jvm's providing. Furthermore console tools are often very handy, focused on one or few tasks, they are low resource consuming and you can build chains of such tools and reuse them in your way. So let's look on them.

jps

Since jdk 1.5.0

The name of the command suggest that is similar to know UNIX ps but for java processes. So jps, when it called without parameters list all java processes on the local machine, which is very handy. Let's look on some examples.

jinfo

Since jdk 1.5.0 (Will not be able connect to jvm's version below 1.5)

Next interesting command is jinfo. jinfo prints configuration information for a given Java process or core file or a remote debug server. Information details include Java System properties and command line flags. Here is example with shortened output.

jmap

*Since jdk 1.5.0 (Will not be able connect to jvm's version below 1.5)
*
jmap list information about shared objects used by a java process. Also it lists heap memory details. Here further examples again.

This is very usefull for detailed analysis of heap, which iss done whith the nex tool.

jhat

Since jdk 1.6.0

jhat parses a java heap dump file, launches a webserver on default port 7000. So it is possible to browse through the heap. jhat even supports Object Query Language) (OQL) to query heap dumps. To look inside the genrated heap dump we execute:

I my case we can see some increase of Eden Space utilization (EU) during the time. Please look to the documention for further information to other options. If you wannt to be able to track jstat of remote machines, you can wire them by utilising jstatd command on the remote side.

jstack

Since jdk 1.5.0

Abowe we saw GC, memory and Heap statistics, now is time for Threads, that is where jstack comes to play. jstack prints Java stack traces for a given Java process or core file or a remote debug server.

This is a very small stacktrace, i've cutet some threads of my application also i've cuttet a trace of
"Reference Handler" and "Finalizer" threads. So what you see it typical situation for a small app. JVm uses many threads for it's internal task. So you can see that my jvm chooses to use Parallel GC with 4 Threads, which is good choise for my 4 cores Laptop ;) My application do not run into detlocks, so we se no message about it, otherwise we would see it clearly.
Remote usage of jtrack is possible through jsadebugd.