I install the server nogui version of Ubuntu.   SSH can access your headless server to install everything for Minecraft.

Install the new version of JAVA

I am going to use 1.21.1 versions so JAVA 21.x will work

sudo apt install default-jre

 java -version
openjdk version “21.0.4” 2024-07-16
OpenJDK Runtime Environment (build 21.0.4+7-Ubuntu-1ubuntu224.04)
OpenJDK 64-Bit Server VM (build 21.0.4+7-Ubuntu-1ubuntu224.04, mixed mode, sharing)

Update your server at this point

sudo apt update
sudo apt list --upgradable -a
sudo apt dist-upgrade

Install screen

  apt install screen

Install minecraft and microsoft forge

cd /opt
    mkdir minecraft
    cd minecraft

Only use files.minecraftforge.net for your files.   Other sources can be infected files.

Go to:  https://files.minecraftforge.net/net/minecraftforge/forge/

I went to 1.21 and under it is 1.21.1

Right click on installer in the middle of the screen and copy address link.

 

sudo wget https://adfoc.us/serve/sitelinks/?id=271228&url=https://maven.minecraftforge.net/net/minecraftforge/forge/1.21.1-52.0.24/forge-1.21.1-52.0.24-installer.jar
java -jar forge-1.21.1-52.0.24-installer.jar --installServer