Let's get started with a simple HelloWorld example, as follows:
class HelloWorld { public static void main(String[] args) { System.out.println("Hello World - This is being recorded"); } }
To start flight recording for the preceding application, execute the following command on your console:
> java -XX:StartFlightRecording,filename=hello.jfr HelloWorld
The first line instructs the Java Runtime to start flight recording for your HelloWorld application and save it to the HelloWorldRecording.jfr file.
There are three parts to the previous command, as follows:
- Starting JFR with the -XX:StartFlightRecording JVM option
- Specifying the target file to save the recording to hello.jfr
- Specifying the application to run HelloWorld
Let's start MC to view the profiling data stored in hello.jfr. Use the jmc.exe file...