Java 21 for Minecraft Servers
Minecraft servers from 1.20.5 to 1.21.11 require Java 21 or newer (class file version 65), according to Mojang's version data. Eclipse Temurin 21 is a free, widely used build.
Minecraft versions that need Java 21
According to Mojang's version data, these Minecraft releases require Java 21 as the minimum (newer Java versions also work for vanilla and Paper-family servers):
1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5
Snapshots and pre-releases of these versions have the same requirement. Full table: Minecraft → Java versions.
Install Java 21 (Eclipse Temurin)
Temurin is a free OpenJDK build from the Eclipse Adoptium project. Download installers from adoptium.net — Temurin 21 , or use a package manager:
REM Windows (winget) winget install EclipseAdoptium.Temurin.21.JDK # macOS (Homebrew) brew install --cask temurin@21 # Debian/Ubuntu — after adding the Adoptium apt repository (see below) sudo apt install temurin-21-jdk
Adding the Adoptium apt repository (from Adoptium's installation docs):
sudo apt install -y wget apt-transport-https gpg
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
sudo apt install temurin-21-jdkA server only needs the runtime, so temurin-21-jre also works (its folder is then temurin-21-jre-amd64); the commands here use the JDK for consistency. Other distributions (dnf, zypper, apk): see Adoptium's Linux instructions.
Check it and use it for your server
Open a new terminal and run java -version. For Java 21 the first line starts with openjdk version "21.. If another version appears, your PATH points to a different Java — call the right one by full path in your start script:
REM Windows: see dir "C:\Program Files\Eclipse Adoptium" for the exact folder "C:\Program Files\Eclipse Adoptium\jdk-21…-hotspot\bin\java.exe" -Xms4G -Xmx4G -jar server.jar nogui # macOS "$(/usr/libexec/java_home -v 21)/bin/java" -Xms4G -Xmx4G -jar server.jar nogui # Linux (Adoptium packages; check: ls /usr/lib/jvm) /usr/lib/jvm/temurin-21-jdk-amd64/bin/java -Xms4G -Xmx4G -jar server.jar nogui
On Debian/Ubuntu you can instead switch the system default with sudo update-alternatives --config java. The start script generator writes a script that checks the Java version first.
Error message for Java 21 jars
A server jar that needs Java 21, started with an older Java, fails with UnsupportedClassVersionError mentioning class file version 65.0:
… 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 …
Install Java 21 as above and make sure the start script uses it. Walkthrough: fix UnsupportedClassVersionError.