Skip to content

Troubleshooting

Which Java version do Minecraft plugins need? 8, 17, 21 or 25

The Java version for each Minecraft version, what UnsupportedClassVersionError means and how to check which Java your server runs.

· Updated · 3 min read
Cover image: Which Java version do Minecraft plugins need? 8, 17, 21 or 25

A plugin is compiled for a specific Java version, and the server must run that version or a newer one. If it runs an older one, the plugin fails with an error about a class file version. Here is what to use and how to fix the error.

Java by Minecraft version

  • Minecraft 1.8 to 1.16: Java 8 is enough, newer also works on most servers.
  • 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.x: Java 25.

A plugin compiled for an older Java than the server uses still loads. The other direction does not work: a jar built for Java 21 cannot run on Java 17.

The error

java.lang.UnsupportedClassVersionError: dev/example/MyPlugin 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

The numbers are class file versions: 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 plugin needs Java 21 and the server runs Java 17.

How to check what your server runs

Run java -version in the server terminal, or look at the first lines of the server log, which print the Java version on start. On a hosting panel there is usually a Java version setting in the startup options.

How to fix it

  1. Best: rebuild the plugin for the Minecraft version you actually run. The tool then compiles for the right Java.
  2. Or update Java on the server to the version in the list above. Hosts let you pick it in the panel.
  3. Do not mix: running a 1.20.4 server on Java 21 is fine, but the plugin must match the Minecraft API you built against.

Why this matters for generated plugins

PluginForge picks the Java level from the version you choose, so a plugin for 1.20.4 targets Java 17 and one for 1.21 targets Java 21. Choosing the right version in the creator is the whole fix for this error.

Quick reference

Minecraft            Java    class file version
1.8 - 1.16            8       52
1.17                  16      60
1.18 - 1.20.4         17      61
1.20.5 - 1.21.x       21      65
26.x                  25      69

Running several servers with different Java versions

If you host more than one server, give each its own Java through the panel or a launch script instead of changing the system default. That way an old 1.16 server and a new 1.21 server can live on the same machine without breaking each other.

Frequently asked questions

Can I run a 1.8 server on Java 21?

Usually the old server software has trouble on much newer Java. Keep legacy versions on Java 8 unless the software says otherwise.

Does the plugin need a JDK or only a JRE?

Only a runtime is needed to run it. A JDK is needed to build plugins from source.

Why does the generator ask for a version?

The version decides the API and the Java level the plugin is compiled for, which is how the error in this guide is avoided.

Written by

PluginForge Team

We build PluginForge, the AI Minecraft plugin creator. The guides come from what we see when plugins are generated, compiled and installed on Paper and Spigot servers.

More guides

RSS feed · All guides