Which Java version does my Minecraft server need?
The Java version for every Minecraft release from 1.12 to 26.x, how to read the "class file version" error, and what JVM flags do.
A Minecraft Java Edition server is a Java program, and each Minecraft release is built for a particular version of Java. Run it on one that is too old and it refuses to start; run an old modded server on one that is too new and it can crash halfway through loading. This page has the table, the errors you see when it is wrong, and what the “flags” people talk about actually do.
The table
- Minecraft 1.16.5 and older — Java 8. Old Forge versions in particular break on anything newer.
- Minecraft 1.17 — Java 16.
- Minecraft 1.18 to 1.20.4 — Java 17.
- Minecraft 1.20.5 to 1.21.x — Java 21.
- Minecraft 26.1 and newer (the year-based version numbers) — Java 25.
These are the versions each release shipped with — the safe choice. A newer Java often runs an older Vanilla or Paper server fine, but modded servers are much less forgiving: their tooling reads the game’s code at a low level and can choke on a runtime it was never tested against.
On a Cobbly server
You do not choose Java at all. The server picks the right runtime from the table above every time it starts, based on the Minecraft version on the Software tab — including for CurseForge modpacks, where it reads the version the pack was actually built for. Change the version and the Java version follows.
The "class file version" error
The most common Java error looks like this:
java.lang.UnsupportedClassVersionError: … has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
It means some code was built for a newer Java than the one running it. Class file versions map to Java versions like this: 52 is Java 8, 60 is Java 16, 61 is Java 17, 65 is Java 21, and 69 is Java 25. In the example, the code needs Java 21 and the server is running Java 17.
If the class it names is the server itself, the Java version is wrong for that Minecraft version. If it names a mod or plugin, that file was built for a newer Minecraft than your server runs — remove it or download the right version.
The opposite problem
An old modded server on a too-new Java fails less clearly. Typical signs: Unsupported class file major version in the log, Mixin errors mentioning many mods at once, or a crash in the mod loader’s own code before any mod has loaded. Forge for 1.16 and older is the usual victim. The fix is the matching Java version from the table — not removing mods one by one.
Running a server on your own PC
If you host at home, install a JDK from Eclipse Temurin (Adoptium) or another OpenJDK build — the version from the table. You can have several installed at once; start the server with the full path to the right java executable rather than relying on whichever one your system finds first. java -version tells you which one that is.
What JVM flags are
Everything after java and before -jar server.jar in a start command is a JVM flag. Two matter most:
-Xmx— the maximum heap, the memory the game can use, for example-Xmx4G. Setting it to all of a machine’s RAM is a mistake: Java needs room outside the heap too, and the operating system needs the rest. How much RAM does a Minecraft server need? covers the split.-Xms— the starting heap. Many guides set it equal to-Xmxso Java does not spend time growing the heap.
The rest are garbage-collector tuning. The well-known set is Aikar’s flags, which tune the G1 collector to make many short pauses instead of a few long ones — fewer stutters on a busy server. They help most on dedicated servers with 6 GB or more. On a small server they make little difference, and on a managed host the start command is usually set for you (on Cobbly it is).
Do not use flags from old guides
Flags that were good advice for Java 8 can be wrong or rejected on Java 17 and later — some were removed entirely, and an unknown flag stops Java from starting. If a guide predates 2021, check every flag before copying it.