Minecraft servers have used Java 8 for quite a while now, but this is slowly starting to change. The new standard is starting to shift over to Java 11, you may have seen the announcement of Paper switching over to Java 11 starting with Minecraft 1.17. With this starting to become the case, you might want to start utilizing Java 11 now. Java 11 also contains the new and improved G1GC garbage collector, which provides some nice performance increases for your server.

This guide will show you how to install Java 11 on your dedicated server running CentOS 7!

Checking which version of Java is currently installed

First things first, you'll want to check to make sure don't actually already have Java 11 installed, you can do so by running the java -version command on your server through SSH (If you do not know how to SSH into your server, we have a guide on how to do this!).

You should get something similar to this:

Checking your currently installed version of Java
In the above screenshot, you'll see the following output:
openjdk version "1.8.0_282"

Which means you currently have Java 8 installed, so let's go ahead and install Java 11 then!

Installing Java 11

To install Java 11, you'll want to run the following command:

yum install -y java-11-openjdk

Download of Java 11 in progress
However, you'll probably notice after running java -version again, that you're still seeing Java 8, however, we'll fix this in the next step.

Setting Java 11 as default

To actually set your system to utilize Java 11, start by running the following command alternatives --config java which will give you a screen similar to this:

Output of the alternatives command

Here you can see the system is presenting us with the versions of Java installed on the system, and each entry contains a number at the start of it. In my example, selection #2 has Java 11, which you can tell by the 11 next to java at the beginning of the command. Type the number next to Java 11 on your system, which again in my case would be 2 then press enter to set the new default.

After choosing a selection, run java -version again to confirm that you're now running Java 11:

Setting a new default version of Java, and confirming the change took place
If you see Java 11, congrats! You should now be able to restart your Minecraft server(s), which should now boot with Java 11. Any other applications on the system should now use Java 11 as well, if it is just using the default installation of Java on the system.
Was this article helpful?
Thank you!