How to fix Java version errors on a Minecraft server

You start your server and the console prints something about a "class file version" or "UnsupportedClassVersionError", then stops. This is one of the most common Minecraft problems, and it has a simple cause: the server software was built for a newer (or older) Java than the one running it. The fix is to match them, and this guide shows how.

What the error means

Java programs are compiled for a particular Java release. Each release has a class file version number. If the program needs a newer release than the runtime provides, Java refuses to load it and prints a message such as:

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

Read the two numbers. The first is what the program needs. The second is what you have. The difference tells you which way to move.

Translating the numbers

Class file versionJava release
52Java 8
55Java 11
60Java 16
61Java 17
65Java 21

In the example above, the program needs class file version 65, which is Java 21, but the runtime only supports up to 61, which is Java 17. You need to move up to Java 21.

Which Java a Minecraft version needs

Requirements have changed over time. As a general guide, recent versions need newer Java, and old versions need old Java:

Minecraft version rangeJava commonly required
Up to 1.16Java 8 (Java 11 often works)
1.17Java 16
1.18 to 1.20.4Java 17
1.20.5 and newerJava 21

Always confirm for your exact version and server software, because requirements can change. The server software's release notes state the minimum. Plugins and mods may add their own limits too.

How to fix it on a panel

  1. Open your server's startup settings and look for a Java version or runtime image option. See What the startup settings on a game server do.
  2. Select the release that matches your game version.
  3. Save and start the server.
  4. Check the console. If the error is gone, you are done.

If the option is missing, the panel may choose the runtime automatically when you change the game version. Try changing the version through the proper tool, or open a ticket with the exact error. See Change your Minecraft version.

How to fix it on your own VPS

Check what is installed and which one is active:

java -version
update-alternatives --list java

Install the release you need (on Ubuntu, for example):

sudo apt update
sudo apt install openjdk-21-jre-headless

If several are installed, choose the default:

sudo update-alternatives --config java

Alternatively, call the exact Java path in your start command, which avoids relying on the system default. Use the full path shown by update-alternatives.

When you upgrade or downgrade the game

Two situations cause most errors:

  • You updated the server jar to a newer version that needs newer Java than the panel is using.
  • You went back to an older version with a Java that is too new. Some very old versions and mods fail on newer Java, in the opposite direction.

If you downgrade, remember that worlds from newer versions may not load in older ones. Take a backup first. See Creating and restoring backups.

Mods and plugins

A plugin or mod compiled for a newer Java can stop an otherwise fine server from loading, with the same type of error mentioning the plugin's file name. The line before the error usually names the file. Remove or update that plugin, or move to the Java version it needs. Mod hygiene for game servers explains how to keep mods consistent.

Other Java messages that look similar

MessageMeaning
"Could not create the Java Virtual Machine"An invalid flag, or a memory value too large for the plan
"Invalid maximum heap size"The memory flag is wrong
"Unable to access jarfile"The file name or path is wrong
"OutOfMemoryError"Not enough memory. See Fix Minecraft out-of-memory errors
"Error: A JNI error has occurred"Often a Java version mismatch

Checking after the change

Start the server and watch the first lines in the console. The server software usually prints which Java it is running. A successful start continues past the loading messages to "Done". If the next error is different, treat that as progress and read it fresh. See How to read your server logs.

Quick checklist

  1. Read the two class file version numbers.
  2. Translate them to Java releases.
  3. Set the runtime or install the right Java.
  4. Restart and read the console.
  5. If a plugin is at fault, update or remove it.

If it still fails, write a clear support request with the full error text and the game version.


Still stuck? Open a ticket on Discord - run /ticket in any channel, pick a department, and include your Server ID or Invoice ID so we can jump straight in.