Fetching and Building OpenJDK Mission Control

Since people keep asking me, I thought I’d put together this quick primer on how to get started with OpenJDK Mission Control. Now, once the early access builds of JMC 7 is out, that will probably be the easiest way to get started for people who don’t want to change stuff. This blog, however, will be for the ones of you who would like to build JMC from source.

Getting Mercurial

First step is to get Mercurial, the SCM used for OpenJDK. JMC (being an OpenJDK project) is available through a Mercurial repository. Installing Mercurial is different for different platforms:

Mac OS X

Easiest is to install through Homebrew:

brew install mercurial

That said, dmg packages can also be downloaded from here: https://www.mercurial-scm.org/wiki/Download.

Windows

Go to https://www.mercurial-scm.org/wiki/Download. Download the InnoSetup based installer and run it. Ensure that the “add to path” checkbox is checked. Verify that the install went fine by opening a command prompt and typing hg and enter. A list of the available commands should be printed.

Linux

For Debian based distributions, you can install using the package manager:

sudo apt-get install mercurial

That said, you can also get rpms and other installation packages from here: https://www.mercurial-scm.org/wiki/Download.

Cloning the Source

Once Mercurial is installed properly, getting the source is as easy as cloning the jmc repo. First change into the directory where you want to check out jmc. Then run:

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

Getting Maven

Since you probably have some Java experience, you probably already have Maven installed on your system. If you do not, you now need to install it. Simply follow the instructions here:

https://maven.apache.org/install.html

Building Mission Control

First we need to ensure that Java 8 is on our path. Some of the build components still use JDK 8, so this is important.

java –version

This will show the Java version in use. If this is not a Java 8 JDK, change your path. Once done, we are now ready to build Mission Control. Open up two terminals. Yep, two!

In the first one, go to where your cloned JMC resides and type in and execute the following commands (for Windows, replace the dash (/) with a backslash (\)):

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

Now, leave that terminal open with the jetty running. Do not touch. In the second terminal, go to your cloned jmc directory and simply run maven:

mvn clean package

JMC should now be building. The first time you build Maven will download all of the third party dependencies. This will take some time. Subsequent builds will be less painful. On my system, the first build took 6:01 min. The subsequent clean package build took 2:38.

Running Mission Control

To start your recently built Mission Control, run:

Windows

target\products\org.openjdk.jmc\win32\win32\x86_64\jmc.exe -vm %JAVA_HOME%\bin

Mac OS X

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

Contributing to JDK Mission Control

To contribute to JDK Mission Control, you need to have signed an Oracle Contributor Agreement. More information can be found here:

http://openjdk.java.net/contribute/

Don’t forget to join the dev list:

http://mail.openjdk.java.net/mailman/listinfo/jmc-dev

If there is interest, I will add a more detailed blog post on this later.

More Info

For more information on how to run tests, use APIs etc, there is a README.md file in the root of the mercurial repo. Let me know in the comments section if there is something you think I should add to this blog post and/or the README!

11 Responses to "Fetching and Building OpenJDK Mission Control"

  1. And here we go with JDK 11…

    org.openjdk.jmc.flightrecorder.internal.InvalidJfrFileException
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.createChunkInput(FlightRecordingLoader.java:155)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.access$0(FlightRecordingLoader.java:146)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader$1.getNextChunk(FlightRecordingLoader.java:108)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.createChunkLoader(FlightRecordingLoader.java:293)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.readChunks(FlightRecordingLoader.java:216)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.loadStream(FlightRecordingLoader.java:95)
    at org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader.loadStream(FlightRecordingLoader.java:76)
    at org.openjdk.jmc.flightrecorder.ui.RecordingLoader.doCreateRecording(RecordingLoader.java:173)
    at org.openjdk.jmc.flightrecorder.ui.RecordingLoader.run(RecordingLoader.java:96)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:60)

  2. […] last blog (about Fetching and Building OpenJDK Mission Control) earned me questions on how to get the source into Eclipse to start playing around with it. This […]

  3. Suresh says:

    Nice for the write-up. One small suggestion I have is to use Maven wrapper https://github.com/takari/maven-wrapper, so that we can remove the getting maven step.

  4. Marcus says:

    Thanks! Well, JMC is open source, so anyone with an Oracle Contributor Agreement can go ahead and propose a change to add the wrapper. Since it is Apache licensed, I am sure it will be an acceptable third-party dependency.

    Join the dev-list here:
    http://mail.openjdk.java.net/mailman/listinfo/jmc-dev

    Looking forward to seeing you there! 😉

  5. Gary Morrison says:

    This is really excellent! Thanks.

    However, does the JMC build work under JDK11? “mvn p2:site” keeps giving me:
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 18.993 s
    [INFO] Finished at: 2018-10-04T17:54:08-05:00
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.reficio:p2-maven-plugin:1.2.0-SNAPSHOT:site (default-cli) on project external-dependencies: Execution default-cli of goal org.reficio:p2-maven-plugin:1.2.0-SNAPSHOT:site failed: org.apache.maven.plugin.MojoExecutionException: Unable to execute mojo: P2 publisher return code was 13 -> [Help 1]

  6. Marcus says:

    Nope, not yet, but we’re working on it. As the readme states, the build currently requires a JDK 8.

  7. Ravikumar Sivaraj says:

    Hi Marcus,
    I’m new to jmc.exe at my work, I get an error saying that the config.ini is non writable. I worked out to it using the user.home variable to go to a directory and first look for config.ini that is writable there. Is there a way to override this as my work has given a non writable directory for this.
    My main goal is to analyse a process to see which methods it calls and how much time per method. I’ve already used the Flight recorder to record the process. But now want some system to unravel the output and give me this information.

  8. Marcus says:

    Hi Gary!

    I should have taken a closer look at the error message – that is an actually error. Seems org.reficio is no longer available. I have a patch open for review.

    Here is the Jira issue:
    https://bugs.openjdk.java.net/browse/JMC-6161

    That said, you do need JDK 8 to build the application. Core you can build with JDK 11 as well.

  9. Will Sargent says:

    Where would I download a pre-built binary of JMC now?

  10. Marcus says:

    Hi there!

    You can reach them through the project page (where you can also see the status for releases).

    Or directly at http://jdk.java.net/jmc/.

    Kind regards,
    Marcus

Leave a Reply

Your email address will not be published. Required fields are marked *