Tuesday, November 13, 2018

How to use Java Mission Control from the source

This blog post is intended to guide everyone who wants to try Java Mission Control and Java Flight Recorder build from the source code.  Although the one of the best  information source is Marcus's blog, very updated, I want to start mine to summarize or remember some parts, it maybe useful :)
  So let's start with quick overview. Maybe you have already heard about Java Mission Control or Flight Recorder before, for those who not Java Mission Control (JMC) is a tool suit for managing, monitoring, profiling and troubleshooting java application. The JMC consists from JMX Console and Java Flight Recorder (JFR). JMC as a tool creates a complete tool chain to collect low level and detailed information not only about Java runtime. The JFR is a tool used for collecting data at the runtime, it has very small overhead as Marcus said during one of the conference talks: "It has been designed since the very beginning for the production time JVM profiling". Already from such sentence you may feel the power of the tool.
  After an Oracle announcement to OpenSource JMC technology last year many people get excited. Currently JMC has still not been released, but it's planed on January 30 2019 (JFR has been released with OpenJDK 11)
 Before this date you can download and try Early Access Builds (hereJMC - Now serving OpenJDK binaries):

http://jdk.java.net/jmc/

If you are fine to build your own JMC build that includes all latest updates,  you are free to go.  In such case you will need to get Mercurial, on Mac OS (mode details here):

$brew install mercurial

Next step is to clone the repository:

$hg clone http://hg.openjdk.java.net/jmc/jmc/

important : Now you will need to open two terminals where in the first one is reserved for exposing p2 repo to your localhost.  

$cd releng/third-party
$mvn p2:site
$mvn jetty:run

Inside the second terminal you need to build and populate the jmc core first

$cd core
$mvn clean install

after the successful install you go back to the jmc folder 

$cd .. 
$mvn package

Having build JMC successfully done you can now run your local build. On Mac Os:

$target/products/org.openjdk.jmc/macosx/cocoa/x86_64/JDK\ Mission\ Control.app/Contents/MacOS/jmc -vm $JAVA_HOME/bin

Final though
  Although you can still enjoy already published binaries the JMC team is still working on improvements before the final release. It is quite handy to pull those changes and build the latest JMC version from the branch

$hg pull

When you are building JMC don't forget to have your local p2 repo running (third-party). It is described in the part marked as important. 
Enjoy JMC !

No comments: