In this tutorial I will try to explain an easy way of setting up a fast java Minecraft server on Ubuntu 20.04. Please keep in mind this is not suitable for the version of Minecraft that is on Microsoft App Store or XBOX etc. This is for the java version.

So first of all you need a working ubuntu 20.04 server either hosted or on your local network. The purpose of this tutorial is not to cover the installation process of ubuntu.

So a working ubuntu server is needed with a non root user already created.

First of all let’s update and prepare the server.

Update our server with the following command.

sudo apt update

The root password will be required plz enter it now.

Next install the OpenJDK version 16 of Java, specifically the headless JRE. This is a minimal version of Java that removes the support for GUI applications. This makes it ideal for running Java applications on a server.

sudo apt install openjdk-16-jre-headless

You also need to use a software called screen to create detachable server sessions. screen allows you to create a terminal session and detach from it, leaving the process started on it running. This is important because if you were to start your server and then close your terminal, this would kill the session and stop your server. to install screen just run the following command.

sudo apt install screen

Also remember to allow traffic to our server if ufw firewall is enabled by issuing the following command

sudo ufw allow 25565

Now we will download our server.

Please visit Minecraft’s Website and copy the link that says Download minecraft_server.X.X.X.jar, where the X’s is the latest version of the server.

Now create a directory on our ubuntu server for our Minecraft installation.

mkdir minecraftww

Move into that directory

cd minecraft

Use the wget command to download the server.jar file from Minecraft’s website using the link we copied in the previous steps.

wget https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar

If you want to download an older version of Minecraft, you can find them archived at mcversions.net.

Ok now time to configure and run the server.

First of all let’s use the screen command we installed earlier to go into a screen session so we can have our server running when we log out. Keep in mind there are other ways to make the server running as a service that I will not cover in this tutorial.

so run

screen

The first time you will be presented with a banner please press space till you find yourself at the $ prompt again.

To perform our initial configuration the server needs to create a few initial files and we need to accept the EULA. So now we try to run the server for the first time. We will be presented with an error about the EULA and it will not run but don’t worry yet.

java -Xms1024M -Xmx1024M -jar server.jar nogui

Please make sure the name of the server file we downloaded earlier is server.jar if not please rename it using the mv command.

So after our initial run and the error about the Eula you should have some extra files now. The one is Eula.txt file and the other is server.properties

First edit Eula.txt using your favourite editor i use nano and replace eula=false with eula=true and save it.

We will discuss the server.properties file on another tutorial with detail. for now view the file below as reference.

#Minecraft server properties
#Thu Apr 30 23:42:29 UTC 2020
spawn-protection=16
max-tick-time=60000
query.port=25565
generator-settings=
force-gamemode=false
allow-nether=true
enforce-whitelist=false
gamemode=survival
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=easy
spawn-monsters=true
broadcast-rcon-to-ops=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
function-permission-level=2
rcon.port=25575
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=false
level-name=world
view-distance=10
resource-pack=
spawn-animals=true
white-list=false
rcon.password=
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=A Minecraft Server
enable-rcon=false

Gamemode setting is important choose survival for a normal game or creative if you just want to build.

Now run our server again by using the following command

java -Xms1024M -Xmx1024M -jar server.jar nogui

Now the server should run normally and create the world

After the server is run you will end up with an output similar to this one

Output[21:08:14] [Server thread/INFO]: Starting minecraft server version 1.15.2
[21:08:14] [Server thread/INFO]: Loading properties
[21:08:14] [Server thread/INFO]: Default game type: SURVIVAL
[21:08:14] [Server thread/INFO]: Generating keypair
[21:08:15] [Server thread/INFO]: Starting minecraft server on *:25565

Now to keep the server running and exit hit CTRL-A-D

This should leave the screen session

By running screen -list command you should see your screen running

OutputThere is a screen on:
        26653.pts-0.minecraft   (03/25/20 21:18:31)     (Detached)
1 Socket in /run/screen/S-root.

To resume it if you want run screen -r command.

The server is ready

Launch Minecraft on your desktop, choose multiplayer and add a new server using the IP of your Ubuntu Server or the hostname if you have one.

You should now be ready to play, have fun.