Fix "UnsupportedClassVersionError" on a Minecraft Server
Updated · MCJarHub
Your server jar was built for a newer Java than the one running it. Read the class file version in the error (e.g. 65.0 = Java 21, 69.0 = Java 25), install that Java version or newer, and make sure your start script actually uses it.
What the error looks like
When you start the server, Java stops immediately with a message like this (the class name at the start differs between Vanilla, Paper, Forge and others):
Exception in thread "main" java.lang.UnsupportedClassVersionError: …/Main 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
On older Java 8 installs the same problem often starts with Error: A JNI error has occurred, please check your installation and try again, and a double-clicked jar on Windows only shows a popup saying "A Java Exception has occurred".
Read it as two numbers: the first class file version is the Java the jar needs, the second is the newest one the Java you are running understands. In the example the jar needs Java 21 (65) but it was started with Java 17 (61).
Class file version → Java version
| Class file version | Java version | Minecraft servers that need it |
|---|---|---|
69.0 |
Java 25 | Minecraft 26.1 – 26.3 |
65.0 |
Java 21 | Minecraft 1.20.5 – 1.21.11 |
61.0 |
Java 17 | Minecraft 1.18 – 1.20.4 |
60.0 |
Java 16 | Minecraft 1.17 – 1.17.1 |
55.0 |
Java 11 | No vanilla release requires exactly this version |
52.0 |
Java 8 | Minecraft 1.2.5 – 1.16.5 |
The Minecraft ranges come from Mojang's version data. Full list: which Java version does my Minecraft server need? Every version page on MCJarHub also shows the required Java.
Fix it in three steps
- Check which Java your server actually runs. Open a terminal in the same place your start script runs and type:
java -version
The first line shows the version, e.g.
openjdk version "17.0.12"means Java 17. Old Java 8 reports itself as1.8.0_…. - Install the Java the jar needs (or newer). Eclipse Temurin is a free, widely used build: Temurin 21, Temurin 25. Step-by-step commands for Windows, macOS and Linux are on Java 21 and Java 25.
- Make the server use it. Installing a new Java does not always change which
javayour terminal or start script finds. The reliable fix is to call it by full path in the start script:REM start.bat (Windows) — adjust the folder name to the version you installed "C:\Program Files\Eclipse Adoptium\jdk-21.0.8.9-hotspot\bin\java.exe" -Xms4G -Xmx4G -jar server.jar nogui pause
# start.sh (Linux, Adoptium .deb package — check the folder name with: ls /usr/lib/jvm) /usr/lib/jvm/temurin-21-jdk-amd64/bin/java -Xms4G -Xmx4G -jar server.jar nogui # start.sh (macOS) "$(/usr/libexec/java_home -v 21)/bin/java" -Xms4G -Xmx4G -jar server.jar nogui
List what is installed with
dir "C:\Program Files\Eclipse Adoptium"(Windows),ls /usr/lib/jvm(Linux) or/usr/libexec/java_home -V(macOS). On Debian/Ubuntu you can also switch the default withsudo update-alternatives --config java.
The start script generator writes a script with a Java version check built in, so the next mismatch prints a clear message instead of a stack trace.
Special cases
- Hosting panels (Pterodactyl, Pelican, etc.): the Java version is part of the server's Docker image. Change the image/"Java version" setting in the panel's startup tab — installing Java inside the container does not help.
- Old modded servers: "or newer" is not always true for modded setups. Forge for Minecraft 1.16.5 and older is generally expected to run on Java 8; if a new Java produces different errors there, go back to Java 8 for that server.
- Plugins and mods: a plugin compiled for a newer Java can throw the same error while the server itself starts fine. The stack trace then names the plugin's class — update Java or use a plugin build for your version.
- Upgrading Minecraft: moving from 1.20.4 to 1.20.5+ needs Java 21, and moving from 1.21.11 to 26.x needs Java 25 — check before you update (see how to update a server).
FAQ
I installed the new Java but still get the error — why?
PATH still finds the old java. Run java -version in the same terminal you start the server from, or put the full path to the new java binary in the start script.