Fix Java version errors (UnsupportedClassVersionError) on Minecraft
Fix UnsupportedClassVersionError and other Java version mismatch errors by matching your server's Java version to your Minecraft version.
Updated · 2 min read
Each Minecraft version needs a specific Java version. If the server, a plugin or a mod was built for a newer Java than the server runs, startup fails with UnsupportedClassVersionError. If you run a very old Minecraft version on a new Java, you get different errors. The fix is to run the Java version that matches your Minecraft version.
The typical error
java.lang.UnsupportedClassVersionError: io/papermc/paper/PaperBootstrap 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
Translate the class file numbers to Java versions:
| Class file version | Java version |
|---|---|
| 52 | Java 8 |
| 55 | Java 11 |
| 60 | Java 16 |
| 61 | Java 17 |
| 65 | Java 21 |
In the example, the server jar needs Java 21 (65.0) but the server is running Java 17 (61.0).
If the class named in the error belongs to a plugin or mod rather than the server, that single plugin or mod needs a newer Java. Either get a build of it for your Java and Minecraft version, or upgrade both.
Which Java for which Minecraft version
General guidance for recent versions:
| Minecraft version | Java version |
|---|---|
| 1.20.5 and newer | Java 21 |
| 1.18 to 1.20.4 | Java 17 |
| 1.17 | Java 16 (17 also works) |
| 1.16.5 and older | Java 8 (some versions also run on 11) |
The newest Minecraft releases can raise the requirement again, so check the version's page on the Minecraft Wiki or the Paper documentation when you upgrade.
Errors from Java that is too new
Older Minecraft versions, and especially old Forge versions, break on newer Java. A common example with old Forge:
java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast
to class java.net.URLClassLoader
This means Forge for an old Minecraft version is running on Java 9 or newer. It needs Java 8.
How to change Java on Schokr
- Stop the server.
- Open your server's Startup settings.
- If the template lets you choose the Java version (often shown as the Docker image or Java version option), pick the one that matches your Minecraft version from the table above.
- Start the server and confirm the error is gone. The startup log shows the Java version in use.
If you do not see a way to choose the Java version for your server, ask in the Schokr Discord.
When you changed Minecraft version
This error often appears right after moving a server to a newer or older Minecraft version. Whenever you change versions:
- Take a snapshot first.
- Match the Java version to the new Minecraft version.
- Update plugins or mods to builds for the new version.
Players see Java errors too
Players' launchers handle Java for them in most cases. If a player gets a Java error launching a modded client, they should update their launcher or let it choose the Java version automatically. That is separate from the server's Java.