Guide to Fix UnsupportedClassVersion Error in Minecraft 1.20.5 Servers
Introduction
When attempting to launch a Minecraft 1.20.5 server on Ubuntu, you may encounter a frustrating error: UnsupportedClassVersionError
. This issue arises because the server's main class, net.minecraft.bundler.Main
, was compiled with a more recent version of the Java Runtime (class file version 65.0) than is currently installed on your system, which only supports up to class file version 62.0. This guide will help you resolve this error by updating your Java Runtime Environment to a compatible version.
CloseX@CloseX:~/minecraft/1.20.5$ java -Xmx1024M -Xms1024M -jar server.jar nogui
Error: LinkageError occurred while loading main class net.minecraft.bundler.Main
java.lang.UnsupportedClassVersionError: net/minecraft/bundler/Main 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 62.0
This is due to the fact that the latest Minecraft server 1.20.5 requires Java 21.
You can download 1.20.5 server from https://www.minecraft.net/en-us/download/server
1. Update Repository
Use the following command to update the repository.
sudo apt update && sudo apt upgrade -y
2. Install openjdk-21-jre-headless
sudo apt install openjdk-21-jre-headless
Let's try starting the Minecraft server 1.20.5 again.
4. Start Server
java -Xmx1024M -Xms1024M -jar server.jar nogui
Congratulations and enjoy your game.
Note: On Debian, openjdk-21-jre-headless is not yet included in the Debian stable repository. However, it can be found in the unstable repository.
- Edit /etc/apt/sources.list file
sudo nano /etc/apt/sources.list
- Add repository
deb http://deb.debian.org/debian sid main
- Click
ctrl
+o
to save file and clickctrl
+x
to exit
Then update the repository and install openjdk-21-jre-headless