Starting with Minecraft 1.20.5, both the vanilla server and NeoForge require Java 21. Forge on older versions uses Java 17. Here is how to upgrade.
Which Java Version Do I Need?
| Minecraft Version | Required Java |
|---|---|
| 1.16.5 and older | Java 8 or 16 |
| 1.17 - 1.20.4 | Java 17 |
| 1.20.5+ | Java 21 |
| 1.21+ | Java 21 |
Checking Your Current Java Version
java -version
If it shows anything below 21 for a 1.20.5+ server, you need to upgrade.
Installing Java 21
Linux (Ubuntu/Debian)
sudo apt update
sudo apt install openjdk-21-jre-headless
Verify:
java -version
# Should show: openjdk version "21.x.x"
Windows
Download from Adoptium (Eclipse Temurin) or Oracle. Run the installer.
Multiple Java Versions
If you run multiple servers on different versions, install both Java 17 and 21. Point each server to the correct Java binary in its start script.
Common Issues
Server won't start after upgrading to 1.20.5+: Ensure Java 21 is installed and your start script uses the correct Java path.
"Unsupported class file major version 65" error: You are running Java 17 or older on a 1.20.5+ server. Install Java 21.
Mods crashing after Java upgrade: Some older mods are incompatible with Java 21. Check for mod updates or replacements.
FAQ
Does Minecraft 1.21 need Java 21? Yes. Java 21 is required for Minecraft 1.20.5 and all newer versions.
Can I use Java 22 or 23? Java 21 is the baseline. Newer versions may work but are not officially supported.
Does Fabric need Java 21? Fabric itself supports multiple Java versions. But Minecraft 1.20.5+ requires Java 21 regardless of mod loader.
Related: Best JVM arguments for Minecraft, GraalVM for Minecraft, ZGC vs G1GC