In this tutorial, we will install Java and setup a Minecraft server on an Ubuntu VPS server.
1. Login to your VPS server using an SSH client.
2. Run the following commands to install Java 8. When prompt, select Yes and press Enter to agree to Oracle terms and conditions.
sudo apt-get install -y software-properties-common python-software-properties
sudo apt-get update
sudo apt install openjdk-8-jdk
3. Once Java is installed, we can setup the Minecraft server. First, create a directory where we can add the Minecraft server files.
4. Upload the Minecraft JAR file (You can also use Spigot or other Minecraft jar files) to the /Minecraft folder.
5. Now, we have to create a screen to run our Minecraft server on. The screen allows the Minecraft server to run in the background, even when you don't have the SSH session open.
screen -S minecraft
6. Now, you can start the Minecraft server using the command below. Replace minecraft_server.jar with the name of the JAR file you uploaded.
java -Xms1024M -Xmx1024M -jar minecraft_server.jar
(Replace 1024 with the amount of RAM you want to allocate to your Minecraft server. The amount of RAM should be less than the RAM allocated to your VPS)
7. Your Minecraft server will start up now. If you want to quit the SSH client and let the server run in the background, you have to detach the screen by pressing Control + A + D keys.
8. To reattach the screen, run this command: screen -r minecraft