JVM flags
Start options for the Java Virtual Machine that runs the server, such as -Xmx for the maximum memory and settings for the garbage collector.
Minecraft Java servers run on the Java Virtual Machine (JVM). JVM flags are options added to the start command, before -jar server.jar, that control how Java runs the server. The most important ones set memory and tune garbage collection.
Memory flags
-Xmxsets the maximum heap memory, for example-Xmx4G.-Xmssets the initial heap. Many server guides recommend setting it equal to-Xmxso the JVM does not resize the heap while running.
The heap is not the only memory Java uses. The JVM also needs memory for its own code, threads and native buffers. If your server or container has a fixed memory limit, leave headroom below that limit instead of giving the heap everything, otherwise the process can be killed for exceeding it.
Garbage collection and Aikar’s flags
Java frees unused memory with a garbage collector. Poorly tuned collection can cause short pauses that show up as lag spikes. “Aikar’s flags” are a widely used set of G1 garbage collector settings for Minecraft servers, recommended in the Paper documentation. They are a sensible default for most servers; copy them from the official source rather than from forum posts, which are often outdated.
Java version
Each Minecraft version requires a minimum Java version. For example, 1.18 to 1.20.4 need Java 17, and 1.20.5 and newer need Java 21. Running the wrong version usually fails immediately with an “unsupported class file version” error.
Where to put them
On a plain jar you add flags to the start command. Newer Forge and NeoForge servers read them from user_jvm_args.txt instead.
Practical tip
More heap is not automatically better. An oversized heap can make each garbage collection take longer, and RAM does not fix a high MSPT. The guide on how much RAM a server needs helps you pick a size.