简体   繁体   中英

How to import lib for JMX and Java mission Control?

Two questions I am having are:

  1. How to Import lib for jmx(i can't import it)?

  2. 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM