Apr 9, 2018

Java Flight Recorder and Java Mission Control for production environments

Please be advised that although you can download Java Flight Recorder and Java Mission Control freely, you may need to pay to use them.

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collection framework built into the Oracle JDK. It allows Java administrators and developers to gather detailed low level information about how the Java Virtual Machine (JVM) and the Java application are behaving. Java Mission Control is an advanced set of tools that enables efficient and detailed analysis of the extensive of data collected by Java Flight Recorder. The tool chain enables developers and administrators to collect and analyze data from Java applications running locally or deployed in production environments.

Starting with the release of Oracle JDK 7 Update 40 (7u40), Java Mission Control is bundled with the HotSpot JVM.

When you launch your Java application with the java command, you can specify options to enable Java Flight Recorder, configure its settings, and start a recording. The following command-line options are specific to Java Flight Recorder:
  • -XX:+|-FlightRecorder
  • -XX:FlightRecorderOptions
  • -XX:StartFlightRecording
These command-line options are available only in the commercial license of the JDK. To use them, you have to also specify the -XX:+UnlockCommercialFeatures option.
You can also control recordings by using Java-specific diagnostic commands. 

The simplest way to execute a diagnostic command is to use the jcmd tool (located in the Java installation directory). To issue a command, you have to pass the process identifier of the JVM (or the name of the main class) and the actual command as arguments to jcmd. 

For example, to start a 60-second recording on the running Java process with the identifier 8888 and save it to myrecording.jfr in the current directory, use the following:

jcmd 8888 JFR.start duration=60s filename=myrecording.jfr

To see a list of all running Java processes, run the jcmd command without any arguments. To see a complete list of commands available to a running Java application, specify help as the diagnostic command after the process identificator (or the name of the main class). The commands relevant to Java Flight Recorder are:
  • JFR.start
    Start a recording.
  • JFR.check
    Check the status of all recordings running for the specified process, including the recording identification number, file name, duration, and so on.
  • JFR.stop
    Stop a recording with a specific identification number (by default, recording 1 is stopped).
  • JFR.dump
    Dump the data collected so far by the recording with a specific identification number (by default, data from recording 1 is dumped).
These commands are available only if the Java application was started with the Java Flight Recorder enabled, that is, using the following options:-XX:+UnlockCommercialFeatures -XX:+FlightRecorder