Minecraft 1.17 and Java related issues
After recent upgrade, I have experienced few, small, issues related to Java version incompatibility. Bu default, my Linux distribution
Debian GNU/Linux 10
provides Java 11. It was perfectly OK for Minecraft 1.16. However, with most recent release of Minecraft, you will notice following errors
minecraft systemd[1]: Started Minecraft Server - Survival. minecraft java[28815]: Error: LinkageError occurred while loading main class net.minecraft.server.Main minecraft java[28815]: java.lang.UnsupportedClassVersionError: net/minecraft/server/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 55.0 minecraft stop_server.sh[28854]: Connection failed. minecraft stop_server.sh[28854]: Error 111: Connection refused
The issue here is, that most recent release of Minecraft (at least server part) requires Java 16. Funny thing is that official documentation still refers to version 1.8 – Setting up the server. Anyways, getting OpenJDK 16 is super easy. All you have to do is to browse here, download file, and unpack it.
> cd /usr/lib/jvm/ > JAVA_URL=https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL > wget ${JAVA_URL}/openjdk-16.0.1_linux-x64_bin.tar.gz > tar zxf openjdk-16.0.1_linux-x64_bin.tar.gz
However, in case you are using systemd for starting Minecraft up, it’s not enough. You have to alter /etc/alternatives. I, personally, install external stuff inside /opt, however, systemd does not like it. It will not run things that are not located inside certain locations. You will get error similar to this one
minecraft systemd[1]: Started Minecraft Server - Survival. minecraft systemd[29502]: minecraft-survival.service: Failed to execute command: Permission denied minecraft systemd[29502]: minecraft-survival.service: Failed at step EXEC spawning /opt/java/jdk-16.0.1/bin/java: Permission denied minecraft systemd[1]: minecraft-survival.service: Main process exited, code=exited, status=203/EXEC minecraft systemd[1]: minecraft-survival.service: Failed with result 'exit-code'.
To make it work, simply put your JDK inside /usr/lib/jvm and alter /etc/alternatives/java link
> ln -sf /usr/lib/jvm/jdk-16.0.1/bin/java /etc/alternatives/java