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. First we will need to build and install the core libraries:

cd core
mvn install

Next run maven in the jmc root:

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!

16 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

  11. Martin Skarsaune says:

    p2:site fails for me as well building on JDK8:

    [ERROR] Failed to execute goal org.reficio:p2-maven-plugin:1.2.0:site (default-cli) on project external-dependencies: Execution default-cli of goal org.reficio:p2-maven-plugin:1.2.0:site failed: A required class was missing while executing org.reficio:p2-maven-plugin:1.2.0:site: org/apache/felix/bundleplugin/BundlePlugi

    Maven setup:
    Martins-MacBook-Pro-2:third-party marska$ mvn -version
    Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T11:33:14-07:00)
    Maven home: /usr/local/Cellar/maven/3.5.4/libexec
    Java version: 1.8.0_152-ea, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/jre
    Default locale: nb_GB, platform encoding: UTF-8
    OS name: “mac os x”, version: “10.13.6”, arch: “x86_64”, family: “mac”

    Revision:
    Martins-MacBook-Pro-2:third-party marska$ hg log
    changeset: 60:bd0c0065130b
    tag: tip
    user: hirt
    date: Sun Oct 21 13:50:15 2018 -0700
    summary: JMC-6174: Document how to use ide update site

  12. Josef says:

    Hi Marcus,

    it seams the build process has changed. I had to first execute

    1) cd core && mvn clean install
    2) cd .. && mvn package

    As stated in the README.md

    “`bash

    cd core

    mvn clean install

    cd ..

    mvn package

    “`

    It would be great if you could update your blog post (section “In the second terminal, go to your cloned jmc directory and simply run maven:”).

    Kind regards,
    Josef

  13. Marcus says:

    Hi Josef,

    Indeed it has. The blog is now updated!

    Kind regards,
    Marcus

  14. Andrew Kew says:

    Hi Marcus
    Great project!
    I am trying to build it and getting missing dependency failure when running p2:site

    [info] Resolving artifact=[javax.mail:dsn:1.4] transitive=[true] source=[false]
    Downloading: http://*.*.*.*/nexus/content/groups/public/javax/mail/dsn/1.4/dsn-1.4.pom
    [WARNING] The POM for javax.mail:dsn:jar:1.4 is missing, no dependency information available
    Downloading: http://*.*.*.*/nexus/content/groups/public/javax/mail/dsn/1.4/dsn-1.4.jar
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 18.426 s
    [INFO] Finished at: 2018-12-06T11:48:13+00:00
    [INFO] Final Memory: 20M/211M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.reficio:p2-maven-plugin:1.2.0:site (default-cli) on project external-dependencies: Execution default-cli of goal org.reficio:p2-maven-plugin:1.2.0:site failed: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact javax.mail:dsn:jar:1.4 in nexus (http://*.*.*.*/nexus/content/groups/public) -> [Help 1]

    ~$ java -version
    java version “1.8.0_161”
    Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

    ~$ mvn –version
    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)

  15. Marcus says:

    Looks like you have old code there. Try getting the latest version, and do mvn clean before doing mvn p2:site and mvn jetty:run.

Leave a Reply

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