Reputation: 1121
Two questions I am having are:
How to Import lib for jmx(i can't import it)?
Can we access Java Mission Control using Code? (like I can see the visualisation of my problem but I want to fetch it into my IDE using code), is it possible?
Upvotes: 5
Views: 504
Reputation: 7069
If you are using Oracle JDK 9+ or OpenJDK 11+, you can access the data in a JFR file using the Flight Recorder API.
For example, to print all the events:
import jdk.jfr.consumer.*;
try (RecordingFile r = new RecordingFile(Path.of("recording.jfr"))) {
while (r.hasMoreEvents()) {
System.out.println(r.readEvent());
}
}
For more information about the API: https://docs.oracle.com/en/java/javase/11/docs/api/jdk.jfr/jdk/jfr/consumer/package-summary.html
Upvotes: 5