Your setup
start.sh
Which Java version does my Minecraft server need?
| Minecraft version | Java version |
|---|---|
| 1.20.5 and newer | Java 21 or newer |
| 1.18 – 1.20.4 | Java 17 |
| 1.17.x | Java 16 (17 also works) |
| 1.12 – 1.16.5 | Java 8 (1.16.5 also runs on 11) |
| 1.11 and older | Java 8 |
If the server stops immediately with UnsupportedClassVersionError, the Java version is too old. Old Forge versions such as 1.12.2 need Java 8 specifically. Mojang's newest releases can raise the minimum again, so check the release notes when you update.
What are Aikar's flags?
Aikar's flags are a set of Java garbage collector settings written for Minecraft servers and recommended by the Paper team. They tune Java's G1 garbage collector for Minecraft's pattern of creating lots of short-lived objects, which reduces the lag spikes caused by garbage collection pauses. They're safe on Vanilla, Paper, Fabric and Forge. For heaps of 12 GB and more, the generator switches to the larger-heap variant.
Generational ZGC is a newer low-pause collector available from Java 21. Some large servers prefer it; it uses a bit more memory and CPU. If you don't know which to choose, use Aikar's flags.
Why set -Xms and -Xmx to the same value?
-Xmx is the most memory Java may use for the heap and -Xms is how much it starts with. Setting both the same (along with AlwaysPreTouch) reserves the memory up front, so Java never has to grow the heap mid-game. Don't set -Xmx to everything the machine has: Java needs a few hundred megabytes outside the heap, and the operating system needs memory too. Tick the "all the memory the machine has" box and the generator leaves that room for you.
Forge and NeoForge 1.17 and newer
Modern Forge doesn't start with -jar. The installer creates run.sh, run.bat and user_jvm_args.txt. Put the memory and flags from this tool into user_jvm_args.txt (one per line is fine) and start the server with the run script.
Common questions
Do Aikar's flags work on Fabric and Forge?
Yes. They're Java garbage collector settings, so they work with any Minecraft server software running on Java.
What does nogui do?
It stops the server opening its own window with a player list and log. It saves a little memory and is required on servers without a desktop.
How much memory should I give my server?
Use our Minecraft RAM calculator. As a rough guide, 2 GB for a few friends on Vanilla or Paper, 4 GB for most SMPs, and 6–12 GB for modpacks.