How to Create a Minecraft (Java Edition) Server on Windows or Ubuntu
Let's create and run a Minecraft server in minutes so you can enjoy it with your close friends.
Minecraft is a creator's paradise, or a weird-looking, locked-down world that annoys you to your core every time you step into it.
Either way, gamers around the world find it irresistible and play Minecraft in large numbers, making it the best-selling video game of all time .
While you can play Minecraft alone, the experience becomes insipid after you end up spending hours mining and crafting.
Hence, you have multiplayer to keep the fun going. Now you can join famous servers and play along with hundreds if not thousands of players.
Or you can make a Minecraft server yourself to have fun with your loved ones.
It is important to know that this guide will create a Minecraft server on your personal PC. Therefore, you should not accept players that you do not trust, as you will reveal your IP address.
And please remember that we will be hosting the Minecraft Java version which runs on Windows, macOS and Linux.
Now that you know enough, let's get started with the real deal.
How to make a minecraft server
Most likely, you will use your own computer for this. However, you can also opt for Minecraft Server hosting for added support and a professional gaming experience for a large number of players.
But we will stick to the assumption that you are using a personal computer.
And since we are installing the Minecraft Java version, we need to install Java first or update it if you already have it.
Installing Java on Windows is quite simple. Visit this Java download page and download the latest version.
For Ubuntu, open a terminal and type sudo apt install openjdk-18-jre and press Enter. At the time of this writing, Java 18 is the latest; you must change it accordingly.
If you want to run Minecraft on a third party cloud server like DigitalOcean, install java with this command instead: sudo apt install openjdk-18-jre-headless. This means that you will be running Minecraft without a graphical user interface.
After that, download and install the Minecraft Java Edition Server to get a single file called server. Just so you know, there are no separate files for Windows and Linux.
After uploading, it would be ideal to create a separate folder for this, since the server will generate more files that you would like to place in a neat place, rather than lying across the main upload folder.
You can then select a Minecraft server with or without a graphical user interface (GUI). While the GUI is handy, you may have additional resources if you choose to use the command line.
However, we will see both.
Minecraft GUI Server
Using the Minecraft GUI server is almost identical on Windows and Ubuntu.
Window
Run the server file.
This will not open anything, instead additional files will be created, including a text file for the End User License Agreement (eula.txt). Open this text file, change eula=false to eula=true and save changes.
This means that you agree to the developer's terms. If you skip this step, the server will shut down as soon as you open it.
After that, double-click the server file again to open its GUI. All prerequisites will begin downloading and you will receive a "Done" message in the lower right corner (just above the empty field) indicating that the server is ready to be hosted.

Ubuntu
Open a terminal and use the cd command to navigate to the Minecraft folder. Alternatively, you can open a specific folder, right-click and choose "Open in Terminal" to have it point directly to that directory.
Now run java -Xmx1024M -Xms1024M -jar server.jar and press Enter.
Xmx and Xms stand for the maximum and minimum RAM your Minecraft server is running, respectively. You can experiment with these values ββto get the best experience. For example, I can change it to: java -Xmx4096M -Xms2048M -jar server.jar which means the Minecraft server will run with 2GB to 4GB of RAM.

This prompts you to accept the license agreement before starting the server. Just like on Windows, find the eula.txt file you just created and modify it by changing false to true.
After that, paste and run the same command:

This will take some time, but you will soon see a GUI popup showing the status of the server.
You may also encounter some errors such as "Could not load module 'canberra-gtk-module. This can be removed by installing certain files, opening a separate terminal and running sudo apt install libcanberra-gtk-module libcanberra-gtk3-module.
Now restart the server and you won't get this error anymore.
While the GUI is great, using the terminal every time you open it can be annoying. So, we will create a script to make it easy to run.
To do this, create any text file in the folder and name it start.sh. Next, open this file with any text editor. Then copy and paste the java -Xmx1024M -Xms1024M -jar server.jar file and save the changes.
Finally, right-click it, type "Properties" at the end of the pop-up window, select "Permissions" at the top, and check the "Allow executing file as a program" box.

Now all you have to do is right click on the start.sh file and select "Run as program" to open the Minecraft server GUI.

So, this is the creation of a Minecraft GUI server. Let's check out the alternative.
Minecraft server without GUI
Perhaps this is the more powerful option of the two and makes more sense for advanced users.
Window
In this method, we won't run the server.jar file directly. Instead, we will create a single start.bat file to start the server on the command line.
First, open the folder containing server.jar and create a start.txt file. Now open the file in Notepad, copy and paste the following code into a text file and save the changes:
java -Xmx1024M -Xms1024M -jar server.jar nogui
Next, rename the file from start.txt to start.bat.
Now double click this start.bat file to start the server for the first time. This will create multiple files with command prompt closing after running the bat file.
The next steps require modifying the eula.txt file, similar to what we did in the GUI method.
Once you do that and restart the bat file, this will be the output:

"Done" at the end means the server is working fine.
Ubuntu
Not having a GUI in Ubuntu means adding nogui to the script file we created earlier in the Ubuntu GUI method. So the new script will be like this: java -Xmx1024M -Xms1024M -jar server.jar nogui
Subsequently, save the changes and run the script to open the Minecraft server in the terminal:

You can type help to get a list of valid commands, or you can check the Minecraft wikipedia .
Finally, we're done with the server creation part.
Now, in order to play on this newly created server, all you have to do is find "Add Server" under "Multiplayer" in the Minecraft launcher. Next, enter localhost or 0 in the server address and click Finish.
This will display the server in the multiplayer menu. Now select a server and click "Join Server" at the bottom.
This will open the game for a local player (you). But you didn't create this for solo play, so let's check out how to play a multiplayer game on your home server.
Placing players on your Minecraft server
You can host others on your Minecraft server on your local area network (LAN) or outside of it.
People on the same network only need the host's internal IP address, which can be obtained by typing ipconfig at the command prompt.

Ubuntu users can type the hostname -I to get the internal IP address:

In this case, it's the start of the result, 192.168.1.32.
Share this with other players and they can join your server by entering it in the server address section of the multiplayer tab.
However, hosting Minecraft for people outside of the local network will require some networking skills to:
The first step is to configure the firewall to allow connections to a specific port number, which you can find in the server properties file created in the main server folder.

So the default port number is 25565.
Subsequently, you need to tell the firewall to allow connections on this port so that your Minecraft friends can join.
Firewall configuration
The firewall configuration depends on your operating system. Since this guide is for Windows and Ubuntu, we will cover both options.
Setting up a firewall in Windows
Press β+R, type firewall.cpl and press Enter.

Essentially, we will be setting inbound and outbound rules on port (25565) for UDP and TCP network protocols. This will be a four step process. Check out this demo where we complete the first step by creating an inbound rule for TCP:
You will repeat this for inbound (UDP) and outbound (TCP and UDP) on the same port.
Setting up a firewall in Ubuntu
On Ubuntu, the firewall is disabled by default, and you can verify this by running sudo ufw status verbose in a terminal.
If it returns with status: inactive, you can enable it with sudo ufw enable.
Then type sudo ufw allow 25565 and press Enter to open port 25565, which by default allows connections in Minecraft.
Now we can check the open port again using sudo ufw status verbose:

Now that we have this port ready for connections, it's time to make it available to others. This process is called port forwarding and can take anywhere from a few seconds to a minute. But we can't explain it here as it depends on your WiFi router.
Find your device and be done with it.
After that, your friends will need your public IP address.
You can get this just by googling my IP address or by visiting something like Whatismyipaddress .

Blurring my public IP confirms the fact that you don't share yours with anyone you don't trust.
The process for joining this server is similar to joining your own server, with the only difference being that they will use the public IP address: port number (for example, 125.245.74.894:25565) in the Server Address section. And don't worry about the server name, it will be obtained automatically.
Summary
This is how you create a Minecraft Java edition server and invite your friends to join it.
It's easy if the entire group is on the same local network. So you just create a server and share your internal IP address.
For players on different networks, it consists of downloading and running a server file from Minecraft, setting up a firewall, port forwarding, and sharing your external IP address.
While it's possible to turn your desktop PC into a small server, you need a powerful server to host and play on at the same time.