5

Problem summary

I'm trying to set up my raspberry pi 4 as a minecraft server as described here. I've installed the default version of java. The output from java -version is

openjdk version "17.0.11" 2024年04月16日

The next step is to launch the server with the command

java -Xmx1024M -Xms1024M -jar server.jar

However, when I try this, I get the following 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 61.0

I assume that this means that the minecraft server uses files written for a later version of Java?

If this is true, how can I get more recent versions of Java for raspberry pi OS?

I imaged the card just yesterday using the Raspberry Pi Imager and did apt update and upgrade.

Linux raspberrypi 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024年03月07日) aarch64

asked Apr 28, 2024 at 14:37
1
  • A bit curious that it requires Java 21 (the latest LTS at the time of writing) while the official Wiki stated it only requires Java 18, but maybe the wiki is outdated... Commented Apr 29, 2024 at 11:00

1 Answer 1

6

a more recent version of the Java Runtime (class file version 65.0)

That's java 22 which is not available in current RaspiOS.

If this is the major purpose for the Pi, you could install an OS that does provide java 22. Unfortunately, this may not be easy as the latest on Ubuntu 24.04 is java 21. Java 22 is in Fedora 39+, which should be installable, but I cannot vouch for how easy that is or how well it works for various purposes (there are not a lot of such users, I think).

Your other choice is to try installing OpenJDK 22 directly:

https://jdk.java.net/22/

You need the 64-bit version of RaspiOS for this (from your question it looks like the kernel is, if you are not sure beyond that just check the output from file /bin/bash, there should be an "aarch64" in the line of output), and download the "Linux / AArch64" package from the link above. Put that in /opt and from there:

sudo tar -xzf openjdk-22.0.1_linux-aarch64_bin.tar.gz

This will take a few seconds. You'll end up with an /opt/jdk-22.0.1. Now:

sudo update-alternatives --install /usr/bin/java java /opt/jdk-22.0.1/bin/java 1
sudo update-alternatives --config java

Don't miss the whole first command, which ends in 1. The second should then give you a numbered list to choose from; pick the one corresponding to jdk-22, and (hopefully) viola. I tried this on a Pi 4 still running RaspiOS 11 (bullseye) and:

> java -version
openjdk version "22.0.1" 2024年04月16日
OpenJDK Runtime Environment (build 22.0.1+8-16)
OpenJDK 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

I'm not a minecraft user, but this should do the trick.

answered Apr 28, 2024 at 16:09
4
  • 1
    Outstanding, thank you. Went with the install directly option and that seems to have worked. Commented Apr 28, 2024 at 20:20
  • Exactly what I was looking for, and is the exact version I needed too. Thank you! Commented Jun 11, 2024 at 4:01
  • "This will take a few seconds. You'll end up with an /opt/jdk-22.0.1". I've tried but there is no 'jdk-22.0.1' in the opt/ directory. I still only have the archive I placed there. When I get in the opt directory to run the tar command, it says permission denied also. Commented Jun 21, 2024 at 19:18
  • All apologies -- that should have had sudo in front of it. Commented Jun 22, 2024 at 13:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.