0

Is there a way to check if a particular jdk (Oracle or OpenJDK) supports Java Flight Recorder ? I have been trying to run my app on OPEN JDK 8 as following

java -XX:StartFlightRecording

But this does not work on OPEN JDK 8. I get following error Unrecognized VM option -XX:+UnlockCommercialFeatures

but does not work

Kire Haglin
  • 6,569
  • 22
  • 27
coder
  • 231
  • 3
  • 11
  • Related: [*Does openjdk 1.8.0_242 supports Java Flight Recorder?*](https://stackoverflow.com/q/61333887/642706) – Basil Bourque Apr 21 '20 at 00:15
  • Related: [Does OpenJDK 11 support Java Flight Recorder?](https://stackoverflow.com/questions/69984944/does-openjdk-11-support-java-flight-recorder) – ThCollignon Nov 16 '21 at 07:01

2 Answers2

1

One way to check if a JVM supports JFR is to do:

$ jdb

Open a second shell.

$ jcmd

Remember the pid of the jdb process and do:

$ jcmd <pid> help

If the JVM list diagnostic commands starting with JFR, it is supported. If the JDK lacks jcmd, JFR is not supported (unless it is a JRockit JVM in which case jcmd is called jrcmd and the command to look for is start_flightrecording).

Kire Haglin
  • 6,569
  • 22
  • 27
0

You need to 'unlock the commercial features' as described here:
https://docs.oracle.com/javacomponents/jmc-5-4/jfr-runtime-guide/run.htm#JFRUH176

The command should look like this:

java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=myrecording.jfr MyApp
pczeus
  • 7,709
  • 4
  • 36
  • 51
  • Thank you. But this does not work on OPEN JDK 8. I get following error Unrecognized VM option -XX:+UnlockCommercialFeatures – coder Apr 20 '20 at 23:24
  • Outdated information. Oracle has open-sourced both Flight Recorder and Mission Control on the OpenJDK project. Available free-of-cost. See [JEP 328: Flight Recorder](https://openjdk.java.net/jeps/328) and [Mission Control project page](https://openjdk.java.net/projects/jmc/). – Basil Bourque Apr 21 '20 at 00:12