Sign inGet started
Minecraft · Java flags

Java flags generator for Minecraft servers

Build the exact startup command (-Xms/-Xmx, Aikar, G1GC, ZGC or Shenandoah) for your RAM and Java version, ready to paste into your start.sh, start.bat or Pterodactyl JAVA_OPTS variable.

Got your flags? Now you need the serverMinecraft hosting with real NVMe, a dedicated IP and automatic provisioning — paste your command and boot up.
View plans
Server RAM (-Xms / -Xmx)6 GB

The community standard for Paper/Spigot with 4 GB or more.

start.sh
java -Xms6G -Xmx6G -Djava.awt.headless=true -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
JAVA_OPTS
-Xms6G -Xmx6G -Djava.awt.headless=true -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true

The server port (default 25565) is set with server-port in server.properties, not a Java flag — these 22 flags only affect the JVM.

Why -Xms and -Xmx should always be equal

-Xms sets the initial heap the JVM reserves at boot, and -Xmx the maximum it can grow to. On a dedicated server (running 24/7, not sharing that RAM with anything else) there's no reason to leave a gap between them: every time the JVM needs to grow the heap from -Xms toward -Xmx, it has to ask the OS for more memory and reorganize its internal regions, which causes a noticeable stop-the-world pause right when the server is already under load. If -Xms and -Xmx are equal from boot, the JVM reserves the whole heap once and skips that resize entirely. The only downside is a slightly slower startup, a much smaller price than a lag spike with players online.

What G1GC pause-time tuning actually does

G1GC (Garbage-First) splits the heap into small regions and prioritizes collecting the ones with the most garbage first, instead of scanning the whole heap at once like older collectors. -XX:MaxGCPauseMillis=200 isn't a hard guarantee, it's a target: G1 dynamically adjusts how many regions it collects per cycle to try to stay under that pause time. Aikar's flags also tune when the concurrent collection cycle kicks off (InitiatingHeapOccupancyPercent=15, much earlier than the JVM's 45% default) so G1 has plenty of time to clean up garbage before the heap fills up and forces a long, rushed pause. That's why this flag set cuts lag spikes so much on Paper/Spigot compared to Java's defaults.

More RAM isn't always better: the page cache problem

This is a very common mistake: giving Java almost all of the VPS's RAM "so there's plenty to spare." The OS uses free RAM (RAM not reserved by any process) as a disk cache (page cache) for the world region files (.mca) that Minecraft constantly reads and writes. If you give -Xmx nearly all the server's RAM, you leave no room for that cache, and the OS has to read those files from disk over and over instead of serving them from memory — which causes MORE I/O lag, not less, even with a huge, mostly-free Java heap. The practical rule: give -Xmx the RAM your server actually needs for its player count and loaded worlds, and leave the rest of the VPS's RAM free for the OS and the page cache.

When does ZGC help, and when is it overkill?

ZGC is an ultra-short-pause collector (typically under 1ms) that achieves this by doing almost all its work concurrently, in parallel with the server's normal execution. The tradeoff is that concurrent work costs more CPU and needs large heaps so it never has to rush — with little RAM (under 8-10 GB) it often performs worse than a well-tuned G1GC, since it has no spare room to work calmly. Where ZGC really shines is on large servers (16 GB+ heap, networks with many players, or heavy modpacks) where G1's pause spikes, though rare, are unacceptable. For a small or medium server with 4-16 GB, Aikar's flags (tuned G1GC) almost always give a better real-world result.

Where this goes: in the start script, not server.properties

These flags are command-line arguments for the Java process itself (start.sh on Linux, start.bat on Windows, or the JAVA_OPTS/STARTUP variable on a panel like Pterodactyl) — they don't go inside server.properties, which only configures the game itself (port, difficulty, whitelist, etc.), nothing JVM-related. If you use a hosting panel, look for the "startup command" or "Java arguments" field and paste the full command or just the flags there, depending on what your panel asks for.

FAQ

How much RAM do I give Java vs. my VPS?+

Always leave 1-2 GB free for the OS, the panel (if you use one) and the disk page cache, even on a VPS dedicated only to Minecraft. For example, on an 8 GB VPS, give Java -Xmx6G at most, not the full 8 GB.

Do these flags work the same for Paper, Spigot, Fabric, Forge and vanilla?+

Yes, they're JVM (Java) flags, not server-software flags — they work the same no matter which .jar you launch afterward. The difference is how much each benefits: Paper/Spigot get cited most with Aikar's flags because the community tested them there first, but G1GC/ZGC/Shenandoah tune the JVM in general, so they also help on Fabric, Forge or vanilla.

With little RAM (2 GB) do I still need these flags?+

With 2 GB or less, Aikar's tuning has little room to work and sometimes makes no noticeable difference — plain G1GC (or even your Java's default collector) is usually enough. Fine tuning really starts to show from around 4 GB of heap upward, which is also the minimum we recommend for a server running plugins.

Why does the tool sometimes change the GC I picked?+

Because ZGC and Shenandoah need a minimum Java version to work (17+ and 11+ respectively). If you pick a Java version older than what that collector needs, we generate plain G1GC instead so the command actually boots without errors, and we flag it with a warning banner above the result.

Got your flags? Now you need the server

Minecraft hosting with real NVMe, a dedicated IP and automatic provisioning — paste your command and boot up.

View plans
Minecraft Java Flags Generator — Aikar, G1GC, ZGC