This article continues our learning through the Java Mission Control (JMC) tool. Within it, we will learn how to run JMC as standalone application or as Eclipse IDE plugin.
Firstly, if you are new to Java Mission Control, we recommend checking this article for a brief introduction to it: How to use Java Mission Control to monitor Java apps
Then, let’s check which are our options to run it within Eclipse. At the time of writing, the Eclipse Marketplace still references a deprecated version of Java Mission Control.
On the other hand, if you want to use an updated version of JMC, the latest set of artifacts is available at: https://adoptopenjdk.net/jmc.html
From there, you can download Java Mission Control in two flavours:
- Final JDK Mission Control: This is a standalone tool that you can download and install it on your machine
- Eclipse Update site: This is a zip archive you can use directly in your existing Eclipse IDE
Let’s see both options.
Installing JDK Mission Control standalone
From the AdoptJDK page, download Final JDK Mission Control for your operating system. For example, on a Linux machine, the file is org.openjdk.jmc-8.1.0-linux.gtk.x86_64.tar.gz
Unzip the file in a location of your likes, then start Java Mission Control:
$ cd "JDK Mission Control" $ jmc
Once started, expand the “JVM Browser” tree in the top left corner. You will be able to see all active JVMs and attach to them with Java Mission Control:
By selecting the MBean Server, you will be able to monitor your JVM in the central Panel. The main Panel includes a set of options. In the upper part you will find:
- Overview Tab: From this tab you will be able to add/remove charts and add attributes to it. Begin by clicking on the + Add chart button to add a blank chart. Then click on + Add attributes to your Chart.
- Dashboard Tab: From this tab you will see an handy set of Gauges for the most common elements (Heap Memory, CPU usage, Live Set+ Fragmentation)
Moving to the lower set of Panels, you can access to the following set of options:
- MBean Browser: This is where you can browse through the MBeans available in the platform MBean server. As for any other JMX tool, you can look at Attributes, execute Operations or receive Notifications
- Triggers: This option allows to add/remove triggers when CPU/Threads reach a critical threshold
- System: This option provides overall System Information for the Host which runs the JVM
- Memory: This option shows the JVM compisition (Young/Old Generation) and their Active Memory Pools
- Threads: This view contains the list of running Threads. What’s worth to know is that you can enable CPU profiling for them as well as Deadlock detection and their Allocated Memory
- Diagnostic Commands: This option allows to issue JVM diagnostic Command (such as JFR.start) which you would normally send through the jcmd toolkit
Finally, back to the JVM Browser, you can choose to start a Flight Recorder session by right-clicking on the Flight Recorder | Start Flight Recording.
That will begin a Flight Recording session which can then be inspected from Java Mission Control.
Installing JDK Mission Control Eclipse plugin
From the Adopt OpenJDK page (https://adoptopenjdk.net/jmc.html ) you can also download a zip archive that you will install as Eclipse plugin. This will allow you to use Java Mission Control and the Flight Recorder in an Eclipse perspective.
Firstly, download the update site archive (for example, org.openjdk.jmc.updatesite.ide-8.1.0.zip )
Then, from the menu choose Help | Install new Software and then Add as a repository the zipped archive:
Click Next and Finish the Installation. You need to restart Eclipse at the end of this process.
Next, when you restart Eclipse, you will be able to switch to the Mission Control perspective:
By selecting the Mission Control perspective you will see in your Eclipse window the JVM Browser interface, just like we did for the standalone installation.
This article covered the basic steps for installing Java Mission Control on Eclipse and as standalone Java application. It should give you an idea of how JMC, MBeans and the JFR all work together inside the Java Mission Control tool.