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.


1
2
3
4
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.

1
sudo apt update && sudo apt upgrade -y

2. Install openjdk-21-jre-headless

1
sudo apt install openjdk-21-jre-headless

Let’s try starting the Minecraft server 1.20.5 again.

4. Start Server

1
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.

  1. Edit /etc/apt/sources.list file
1
sudo nano /etc/apt/sources.list
  1. Add repository
1
deb http://deb.debian.org/debian sid main
  1. Click ctrl+ o to save file and click ctrl+x to exit

Then update the repository and install openjdk-21-jre-headless

Reference

  1. https://dannyda.com/2024/04/25/how-to-fix-minecraft-server-1-20-5-linuxgsm-java-error-java-runtime-only-recognizes-class-file-versions-up-to-61-0-on-debian-12/


  2. https://blog.closex.org/posts/20044/index.html