One of the reactions to my recent blog on JCMD has been “But, why?”. It is a reasonable question – after all, the simple examples I added to the blog can be solved using existing tools (jps, jstack etc) in the bin folder of any recent JDK. The answer is that JCMD provides:
- A simple framework for easily adding more (self documenting) commands to the JVM.
- One launcher to learn how to use.
- The launcher is backwards and forward compatible. In other words, you can use an old version of the command to connect to a more recent version of the JVM, and vice versa.
- There are already diagnostic commands available that are not covered by the old j* tools, such as the ability to control the JMX agent and the Flight Recorder. In the future more commands will be added.
- In a future JDK update, a JMX interface will allow programmatic access to the diagnostic commands.
For a hint at what will be available in the future, check the JRCMD chapter in the JVM book.