How to start Java Flight Recorder in Java 25
Java Flight Recorder, commonly called JFR, is built into the JDK and records JVM and application events with low overhead. Java Mission Control, or JMC, can open the resulting .jfr files and help you investigate CPU activity, allocation, garbage collection, threads, locks, I/O and other runtime behavior.
You do not need an Eclipse plugin to use JFR. For a modern Java 25 workflow, the three most useful approaches are to start a recording when the JVM launches, start one dynamically with jcmd, or start one interactively from Java Mission Control.
1. Start JFR when Java starts
The easiest approach for a JVM you control is the -XX:StartFlightRecording option.
java \
-XX:StartFlightRecording=filename=app.jfr,duration=60s,settings=profile \
MyApplicationThis starts a recording with the JVM, records for 60 seconds and writes the result to app.jfr.
For longer-running production-style recordings, use the lower-overhead default settings and optionally constrain the disk repository:
java \
-XX:StartFlightRecording=filename=app.jfr,settings=default \
-XX:FlightRecorderOptions=maxchunksize=12M \
MyApplicationOld examples often include -XX:+FlightRecorder. That flag is unnecessary on modern JDKs because Flight Recorder is already available. Likewise, old commercial-feature unlock flags should not be copied into current Java configurations.
2. Start Flight Recorder dynamically with jcmd
If the JVM is already running, use the JDK’s jcmd diagnostic utility. First list the Java processes:
jcmdAssume the target JVM has process ID 1836. Start a one-minute recording like this:
jcmd 1836 JFR.start \
name=production-profile \
settings=profile \
duration=60s \
filename=production-profile.jfrYou can inspect active recordings:
jcmd 1836 JFR.checkYou can also dump an active recording without stopping the JVM:
jcmd 1836 JFR.dump \
name=production-profile \
filename=snapshot.jfrFor a recording without a predefined duration, stop it explicitly and write the result to disk:
jcmd 1836 JFR.stop \
name=production-profile \
filename=production-profile.jfr3. Start JFR from Java Mission Control
Java Mission Control provides a graphical workflow. Launch JMC, locate the running JVM in the JVM Browser, open the Flight Recorder controls and start a recording. JMC lets you choose recording duration and configuration before collecting the events.
When the recording finishes, JMC can immediately open the file and display automated analysis, event views, memory behavior, thread activity, hot methods and other runtime information.
Inspect recordings from the command line
The JDK also includes the jfr command. You can inspect a recording without opening JMC.
jfr summary app.jfrPrint selected event types:
jfr print \
--events jdk.CPULoad,jdk.GarbageCollection \
app.jfrView metadata about the event types stored in a recording:
jfr metadata app.jfrdefault vs profile JFR settings
JFR ships with recording configurations designed for different levels of detail. The default configuration is appropriate for continuous, low-overhead recording. The profile configuration collects more information and is useful for shorter diagnostic sessions where additional overhead is acceptable.
For production troubleshooting, a useful pattern is to keep a low-overhead recording available and capture or dump the relevant window when a performance problem occurs.
Java 25 Flight Recorder workflow
- Use
-XX:StartFlightRecordingwhen the recording should begin with JVM startup. - Use
jcmd <pid> JFR.startwhen you need to profile an already-running JVM. - Use Java Mission Control when you want an interactive graphical workflow and immediate analysis.
JFR is part of the modern JDK, so profiling no longer depends on Eclipse or special commercial JVM options. Start the recording with the mechanism that best fits your deployment, save the .jfr file, and analyze it with JMC or the JDK’s jfr command.
Cameron McKenzie is an AWS Certified AI Practitioner, Machine Learning Engineer, Solutions Architect and author of many popular books in the software development and Cloud Computing space. His growing YouTube channel training devs in Java, Spring, AI and ML has well over 30,000 subscribers.