Vanilla Java
There are a few different vanilla Minecraft server clients. The obvious first being the official Mojang one. That isn't as optimized as it can be, so people have created better versions. Bukkit and PaperMC are notable. For this guide I'll be using Paper. The process is identical with all of them.
​
The newest versions of Minecraft need an updated version of Java! Be sure to download and point everything to the right version.
INSTALL PAPERMC
​
Now we’re going to want to download some server files. Head here:
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Grab the latest build for whichever version you need.
​
Rename the file you downloaded from paper-###.jar to just paper.jar. Make sure it's sitting in your Downloads folder.
​
Put this file in the directory /opt/minecraft/paper. Navigate to your Downloads and open terminal (cd to ~/Downloads). Make the directory if you haven't. Copy the file. Then set the folder’s permissions again.
​
sudo mkdir /opt/minecraft/paper
​
sudo cp paper.jar /opt/minecraft/paper
​
sudo chown -R minecraft /opt/minecraft
​
​
***If you don't set the folder's permissions the server won't be able to run! You'll get errors that say "access denied"***
​
Now we can start the server! It'll shut itself down since we need to accept the EULA (end user's license agreement).
​
Start the server by navigating to /opt/minecraft/paper and opening a terminal session there (cd).
​
Run this command to start the server:
​
sudo java -Xmx1G -Xms1G -jar paper.jar nogui
​
This runs the server with 1GB of RAM (more on this later).
​
​
​
​
​
​
​
​
​
​
​
​
We need to edit the eula.txt file to say we agree, but we don't have permission. so we’ll use an in-terminal text editor with superuser permissions. Still in the server directory /opt/minecraft/paper, run this:
​
sudo nano eula.txt
​
This will load the text editor Nano and let you edit it without changing permissions of anything. Use the arrow keys and change eula=false to true. Then you can hit Ctrl+O then enter to save, and Ctrl+X to close.
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
You CAN run it run as-is now, but we’re going to set up the server as a system service, so it can start/stop with the system (on boot).
Configure your server.properties and JVM arguements below



Creating a service with systemd
Ubuntu uses a system called systemd and screen to manage services. We can use it to manage multiple Minecraft servers easily.
​
​
Open LeafPad (Start>Accessories>LeafPad) and paste this in (between the underscores):
​
_______________
[Unit]
Description=PaperMC Server:
After=network.target
​
[Service]
WorkingDirectory=/opt/minecraft/paper
User=minecraft
Group=minecraft
Restart=always
ExecStart=/usr/bin/screen -DmS paper /usr/bin/java -Xmx2G -Xms2G -XX:+UseG1GC -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:ParallelGCThreads=2 -jar paper.jar nogui
​
[Install]
WantedBy=multi-user.target
_______________
​
​
This is our service named "PaperMC Server". It's operating out of /opt/minecraft/paper with the user/group "minecraft". Screen (to monitor the server from terminal) will be named "paper". Restarts when closed, unless stopped by systemd itself (systemctl stop paper)
​
Change paper.jar as needed.
​
If you want to run multiple instances with different versions of Java, you can point to the entire directory of binaries instead of just the 'java' command. On the line that starts with ExecStart=, change the java directory to wherever you extracted the files to.
​
If you've followed this guide to the letter you can leave it all the same.
​
​
​
Save this as paper.service somewhere (~/Documents is alright)
All we need to do to use this as a service is copy to /etc/systemd/system and allow it to be executed. Navigate to wherever you saved paper.service and issue these:
sudo chmod u+x paper.service
sudo cp paper.service /etc/systemd/system
Then you can start the systemd service. The command “start” will just run it now. The command “enable” will add it as a service so it starts on boot. Just change to "disable" or "stop" to stop it.
sudo systemctl enable paper
sudo systemctl start paper
sudo systemctl status paper
​
To see the screen as if you ran it from terminal normally:
​
sudo -u minecraft screen -R paper
​
​
​

JVM Arguments and server.properties
​
Java needs to be told how to run to get the best performance, it makes a lot of garbage. Inside your paper.service you'll find this line:
​
... -Xmx2G -Xms2G -XX:+UseG1GC -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XXParalellGCThreads=2 -jar paper.jar nogui
​
​
The "base" command looks like this (if you ran it from the terminal, or edited it in the Minecraft launcher):
​
java -Xmx1G -Xms1G -jar paper.jar nogui
​
​
These are called JVM (Java virtual machine) arguments. We can edit a few things to optimize the server based on your hardware. The rest are ones I've found to work well, and that were recommended by people on Reddit.
​
You can change the amount of RAM with this:
-Xmx2G -Xms2G
​
Number of threads (for garbage collecting - set it to the number of cores your CPU has):
-XXParalellGCThreads=4
​
You can find more info on the best JVM arguments here (Aikar's flags)
Your server.properties can affect performance as well. You'll need to edit it with nano, as you did the eula.txt.
cd over to the server folder /opt/minecraft/paper and use this:
​
cd /opt/minecraft/paper
​
sudo nano server.properties
​
See more on the server.properties here
​
​

Run the server!!!
​
Start the service paper.service with systemd:
​
sudo systemctl start paper
​
View the output of the server with Screen:
​
sudo -u minecraft screen -R paper
​
As long as your port forwarding is correct, you can connect and play! It'll take a moment to start the server, based on your computer's performance and mods/plugins. You can find your public IP (v4) at whatismyip.com
​


NOTE: If you plan on making your server open to the public, you'll need to take necessary precautions before opening up and giving out a path to your home network. Several STRONG recommendations include: SSH hardening, general OS hardening, logging, automatic OS updates, firewalls, intrusion detection/prevention.
​
All of the security-related guides linked are guidelines - a strong mindset of security is required to host public servers. Take it seriously so your home network isn't compromised.