How to Change the Java Version on Your Minecraft Server

Match the right Java version to your Minecraft server version. Java 8, 16, 17, and 21 requirements and how to switch.

Different Minecraft versions require different Java versions. Running the wrong Java version is the #1 cause of "server won't start" errors after a version change.

Java Requirements by Minecraft Version

Minecraft VersionRequired JavaNotes
1.7.10 – 1.16.5Java 8Legacy modpacks (1.12.2, 1.7.10) need Java 8 specifically
1.17 – 1.17.1Java 16Brief transition version
1.18 – 1.20.4Java 17Most common modern version
1.20.5 – 1.21.xJava 21Current modern requirement
1.21.5+Java 21+Future versions may require Java 21 LTS

Forge/NeoForge/Fabric note: Mod loaders mostly follow vanilla's Java requirements, but some mods are stricter. Check the modpack documentation if a specific Java version is recommended.

Change the Java Version

Stop the server

In the XGamingServer Panel, go to Console and stop your server.

Open Startup

Click Startup in the sidebar.

Find the Java version selector

Look for Java Version, Docker Image, or JVM — the exact label varies. The dropdown lets you pick from supported Java versions.

Select the right version

Match your Minecraft version against the table above. Click the dropdown and select the corresponding Java version.

Restart the server

Restart from Console. The server reboots with the new Java version.

Common Java Errors

ErrorCauseFix
UnsupportedClassVersionErrorJava is too old for the Minecraft versionUpgrade Java
java.lang.reflect.InaccessibleObjectExceptionJava is too new for an older Minecraft versionDowngrade Java
Could not reserve enough space for object heapAllocated more RAM than the system hasLower RAM allocation
Error: A JNI error has occurredJava/Minecraft version mismatchCheck version compatibility
Server starts but immediately crashesOften Java version mismatchCheck Console for the specific error

Verify the Active Java Version

In Console, look for the startup log. The first few lines usually show:

[Server] Starting org.bukkit.craftbukkit.Main
[Server] Starting Minecraft server version 1.21.4
[Server] Loading libraries, please wait...

If the version is wrong or the server fails to start, you'll see Java-related errors instead.

Modded Servers and Java

LoaderTypical Java
Forge 1.12.2Java 8
Forge 1.16.5Java 8
Forge 1.18+Java 17
Forge 1.20.5+Java 21
NeoForge 1.20.4+Java 17
NeoForge 1.21+Java 21
Fabric 1.18+Java 17
Fabric 1.20.5+Java 21

Java Memory Flags (Aikar's Flags)

After setting the right Java version, use Aikar's optimized JVM flags to get the best garbage collection performance for Minecraft. These flags are version-aware — Java 17/21 uses different flags than Java 8.

How is this guide?

40% Off — Limited TimeGet your Minecraft server todayInstant setup, DDoS protection, and 24/7 support included.
Get a Server

On this page