Log In

How to Make a Minecraft Java Server

How to Make a Minecraft Java Server
22.04.2024
Reading time: 6 min
Hostman Team
Technical writer

A Minecraft server, or just a game server, is a server that hosts multiplayer games for Minecraft Java Edition. Players can design personalized multiplayer experiences by running their own Minecraft Java server. Owners of servers have the ability to alter game modes, environment settings, difficulty settings, and even install mods or plugins to improve gameplay. A vast variety of gaming experiences, from inventive construction projects to survival challenges, are made possible by this adaptability.

Prerequisites

  • System running in Linux Distribution like Ubuntu 22.04. You can deploy Ubuntu on a cloud server in Hostman.

  • Root access or user with sudo privileges.

  • Minimum 4GB of RAM

After all requirements are met, proceed with the creation of Minecraft Java Server.

Install Java

  1. In order for Minecraft to function, Java must first be installed on the server. To accomplish this, perform the command below to add the PPA of the Java source and press ENTER:

sudo add-apt-repository ppa:openjdk-r/ppa

Image34

  1. Accept this addition by updating the package sources, run command:

sudo apt update

Image12

  1. Java installation is now ready, run the command and type “Y” to install it:

sudo apt install openjdk-17-jre-headless

Image23

  1. Validate if java is installed, run the command:

sudo java --version

Image5

Install Minecraft

  1. After java has been installed, create a directory named /MineCraft in order to have a separate folder for the application. Run the command:
mkdir /MineCraft
  1. Go to the created directory, /MineCraft, by running the command:

cd /MineCraft
  1. To verify if you are working on the newly created directory, run the command below. It should show the path /MineCraft in the output:

pwd
  1. Download the installer from the Official Minecraft Server Download. Run the command below:

wget https://pistondata.mojang.com/v1/objects/8dd1a28015f51b1803213892b50b7b4fc76e594d/server.jar

Image27

When the download has finished 100%, check to see if it is successful. Verify it by running the command below. A file named server.jar should be visible in the output.

ls -lrt

 Image19

  1. The Minecraft server is now prepared for configuration and operation, but before doing so, certain software needs to be installed in order to make sure the server continues to function even after a session ends. This software is referred to as screen. This makes it possible for the Minecraft server to continue operating even if the session is terminated or disconnected. Install screen by running the command:

sudo apt install screen

Image7

Configure Firewall

  1. By default, the firewall on a new Hostman server is disabled. Check the status of the firewall by running the command:
sudo ufw status
  • inactive – firewall is disabled.

  • active – firewall is enabled.

  1. Since the system will be used as a server and several clients will connect to it, it is recommended to enable the firewall for security reasons (like preventing server hacking). 

First, allow port 22 for SSH access. Run the command below:

sudo ufw allow 22

Then allow port 10050 for statistics collection in the control panel.

sudo ufw allow 10050

Lastly, Minecraft uses port 25565 by default. To allow this port, run the command:

sudo ufw allow 25565

Enable firewall so changes will take effect. To do this, run the command below and type “y” to proceed with the operation.

sudo ufw enable
  1. Verify the status of the firewall again and make sure all the ports added are now visible in the firewall table. Run the command below.

sudo ufw status

Image33

Configure Minecraft

The server is now ready to configure and run the Minecraft server.

  1. Go to the terminal and type the command:
sudo screen

Image24

Once the display above is shown, just press the space bar and the session will start.

  1. To do the initial configuration, run the command:

sudo java -Xms1024M -Xmx1024M -jar server.jar nogui

Image18

    • server.jar is the jar file downloaded from the previous step. 

    • Xms1024M: Server starts with 1024 MB (1 GB) of RAM. Depending on user preference, the limit may be increased. 

    • Xmx1024M: Server is configured to consume a maximum of 1024 MB (1 GB) of RAM. Depending on user experience while playing the game, the maximum can be increased anytime if the server is running slow.

    • jar: which server's jar file to launch.

    • nogui: server will not start on a graphical user interface (GUI).

  1. The error that appears below is to be expected; Minecraft does this on purpose to make sure the user have read and agreed to the EULA.

Image26

To fix this error, accept the EULA agreement. To do this, run the command below to open the file eula.txt and change the line eula=false to eula=true.

sudo nano eula.txt 

Image16

Click Ctrl + X, then Y and Enter to save and exit.

  1. Now rerun the command below. The initialization will take time for initial setup. Wait for it to complete.

sudo java -Xms1024M -Xmx1024M -jar server.jar nogui
  1. Verify if the server is up and running by typing help. The server is up and running if the display is like below.

Image13

  1. You can always change the setting of the server by modifying the file server.properties. The common settings used are gamemode, motd, pvp, and difficulty.

Image21

  1. To make sure Minecraft server is listening or accepting connections, run the command below. The output should display (LISTEN).

sudo lsof -i:25565 

Image29

Test Your Minecraft Server

If everything is all set on the server, it is now time to test the server.

  1. Connect to it by launching Minecraft client.

Image10

  1. Click Multiplayer and Add Server.

Image1

  1. Enter the IP address of the Minecraft server created. In this case it is 66.248.207.36. Click Done

Image14

  1. The server will now show on the list of servers on multiplayer.

Image8

  1. Click to join server and wait for it to connect.

Image32

  1. The connection was established between the Server and client. The logs will show that the user (jc) joined the game.

Image9

It is now ready to play.

Image15

Conclusion

In conclusion, setting up a Minecraft server creates an array of opportunities for players to interact, work together, and create in the expansive game world. Even though it might seem difficult at first, a user can successfully set up his own server and go on thrilling multiplayer adventures with friends by following the instructions in this guide. By configuring settings, inviting friends to join, and experimenting with the countless customization options available, a user can create a distinctive and immersive multiplayer environment that offers endless hours of entertainment and companionship.


Share