Fixing the minecraft server for version 1.20.6

Updating Java from JDK 17 to JDK 22 For Linux
MSCS is the tool I use to keep my minecraft servers up to date and running well.

Minecraft Server Control Script (MSCS) is a server-management script for UNIX and Linux powered Minecraft servers.

Today I ran the update command to  update to minecraft  version 1.20.6 and the server would not start!
Long story, I was getting this issue:

Error starting the server: couldn’t retrieve the server’s process ID

Which mscs clearly states is because of the java installation being out of date:

This is usually due to an outdated java installation on your machine when trying to start the minecraft server. Verify that the java version required for your minecraft server version is installed on your machine.

I'm Running Java version 17, but I need 21

A developer blog fabricmc shared that the Java Development Kit, JDK being used by Minecraft 1.20.6 requires version 21.  That's a huge jump from JDK version 17!!

This also marks the end of 32-bit support.

GUIDE: Installing JDK Version 22


Version 17 is as far as my apt-get package manager gets me, so we have to do a manual install.
My server is running Debian 11 x64 (bullseye) so I chose Linux/x64.
If you're following along to fix this on your own server, make sure you pick the right one. 
Find openJDK version 22 here: https://jdk.java.net/22/



Steps to Install

  1. Navigate in your server to the directory where you want this JDK installation to live
  2. use wget to download the jdk-package.tar.gz to the server
  3. unzip with tar xvzf the downloaded jdk-package.tar.gz
  4. export to the $PATH variable
  5. edit to add the variables to ~/.bashrc file
  6. Should be good now, (Disclaimer: I do not know if this breaks other programs that depend on older JDK such as old minecraft servers)
    Here's the commands I used on my server:
lang-bash
      
          
 cd /usr/lib/jvm/
 wget "https://download.java.net/java/GA/jdk22.0.1/c7ec1332f7bb44aeba2eb341ae18aca4/8/GPL/openjdk-22.0.1_linux-x64_bin.tar.gz"
tar xvzf openjdk-22.0.1_linux-x64_bin.tar.gz 
cd jdk-22.0.1/bin

#outputs the version if successful
./java -version
cd ../..

# clean up the file tar.gz
rm openjdk-22.0.1_linux-x64_bin.tar.gz

# also add these two lines to the ~/.bashrc file
export JAVA_HOME=/user/lib/jvm/jdk-22.0.1
export PATH="$JAVA_HOME/bin:$PATH"

nano ~/.bashrc
      
    
Alright! almost done...

Permission denied error

Also, I got a permission denied error so I followed the troubleshooting guide:
If you get a permission denied error when attempting to run a mscs command, please ensure that the minecraft user has the correct permissions set:
lang-bash
      
          
chmod -R u+w /opt/mscs
chown -R minecraft:minecraft /opt/mscs
      
    
lang-shell
      
          
root@vultr:/opt# chmod -R u+w /opt/mscs
root@vultr:/opt# chown -R minecraft:minecraft /opt/mscs

root@vultr:/opt# mscs restart
The cached copy of the version manifest is up to date.
Use the force-update option to ensure a new copy is downloaded.
.estarting Minecraft Server: newWorld
root@vultr:/opt# https://minecraftservercontrol.github.io/docs/mscs^C
root@vultr:/opt# vim ~/.bashrc
root@vultr:/opt# cd 
root@vultr:/opt/mscs/worlds/newWorld# mscs status newWorld
Minecraft Server Status:
  newWorld: running version 1.20.6 (0 of 20 users online).
    Port: 25565.
    Memory used: 1.7GB (3GB allocated).
    Process ID: 708053.
root@vultr:/opt/mscs/worlds/newWorld# 
      
    
Success!

Closing

Not super easy, but I guess I learned how to install a package manually without your package manager.  Alright that's all for now blockheads, happy server managing!

Sources
  1. fabricmc dev blog
  2. Here's the guide I followed to install JDK version 22 myself: https://opensource.com/article/21/9/install-java-manually-linux
  3. Opened a github issue: https://github.com/MinecraftServerControl/mscs/issues/342
updated: 2024-05-18 02:20:48 UTC
back to websites more tutorials