How I turned my Raspberry Pi into a Minecraft server under my desk.
I am using a raspberry pi 4.
First thing I did was enable SSH on my pi, this way I can interface with the raspberry pi from my desktop PC. This is optional. If you are having trouble connecting to your raspberry pi through SSH or port forwarding, you can try PiTunnel. I used PiTunnel to connect to my Raspberry Pi while I had trouble setting up port forwarding. PiTunnel removes the need to port forward and sets up a reverse shell you can connect to.
Install Java
sudo apt update && sudo apt upgrade -y
sudo apt install default-jdk
Create the Minecraft folder
cd
mkdir minecraft
cd minecraft/
Next we will download the server .jar file. Navigate to https://www.minecraft.net/download/server/ and copy the download link. Download it using wget. Make sure you are still in the minecraft folder.
wget https://piston-data.mojang.com/v1/objects/f69c284232d7c7580bd89a5a4931c3581eae1378/server.jar
Now we will run server.jar
java -Xmx1024M -Xms1024M -jar server.jar nogui
[Tip] If you get an error related to java versions, try installing a newer version of java, I had to install java17 using this command
sudo apt install openjdk-17-jdk -y
Next we will get a error message.
[ServerMain/ERROR]: Failed to load properties from file: server.properties
[ServerMain/WARN]: Failed to load eula.txt
[ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
To fix the message we will agree to the EULA using this command:
sed -i 's/eula=false/eula=true/' eula.txt
Now we can run server.jar and launch the server
java -Xmx1024M -Xms1024M -jar server.jar nogui
Now to connect to our new server we are going to get the IP of our raspberry pi using this command
sudo hostname -I
Copy the first IP that comes up and enter that into your minecraft client here:
your finished! If you want to change the server settings you can edit minecraft/server.properties using this command.
cd
cd minecraft
nano server.properties
To start and stop your Minecraft server easier, or to make it run on boot, check out my article here where I show you how to create a service using systemctl.
Thanks for reading, let me know if this helps you. If you got stuck, comment below and I will do my best to help you.