When you use the
java command to start a Java application, you can specify options to enable Java Flight Recorder, configure its settings, and start a recording.
The following command-line options for the
java command are specific to Java Flight Recorder:
-XX:+|-FlightRecorder: Enables Java Flight Recorder (not required for JDK 8u40 and later)
-XX:FlightRecorderOptions: Sets the parameters for Java Flight Recorder
-XX:StartFlightRecording: Starts a recording with the provided parameters, or with the default values
The command-line options for Java Flight Recorder are described in the java chapter of the Java Platform, Standard Edition Tools Reference. These options are available only in the commercially licensed JDK from Oracle. To use these options, you must unlock the commercial features as described in the next section.
Unlocking Commercial Features
Use one of the following methods to access for Java Flight Recorder and related options:
-XX:+UnlockCommercialFeatures option when you start your application with the
VM.unlock_commercial_features parameter for the
jcmd utility to unlock commercial features after the application is running.
Example 1-1 Unlock Commercial Features When Starting an Application
java command unlocks commercial features for an application named
MyApp and starts a recording:
java -XX:+UnlockCommercialFeatures -XX:StartFlightRecording MyApp
Example 1-2 Unlock Commercial Features for a Running Application
jcmd command unlocks commercial features for a Java process with the process ID
jcmd 1968 VM.unlock_commercial_features