Note: With the sudden requirements change of the latest Minecraft Snapshot (21w19a), we have updated this guide to teach you how to get Java 16 on your dedicated server. If you previously went through this guide, it doesn't hurt to run through it again to ensure you're on Java 16

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 16, you may have seen the announcement of Paper switching over to Java 16 starting with Minecraft 1.17. With Minecraft 1.17 Snapshot 21w19a, Minecraft now requires at least Java 16 as well. With this starting to become the case, you might want to start utilizing Java 16 now. Newer versions of Java also contain the new and improved G1GC garbage collector, which provides some nice performance increases for your server.

This guide will show you how to install the latest version of Java (Java 16 at this time) 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 at least Java 16 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 16 then!

Installing the latest version of Java (16)

First, in order to prepare for installing the latest version of Java, lets ensure our server is "aware" that the package is available by updating the epel repository. This can be done by using the command:

yum install -y epel-release

Updating the epel repository
To install Java the latest version of Java (Java 16 at this time), you'll want to run the following command:

yum install -y java-latest-openjdk

Download of Java 16 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 16 as default

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

Output of the alternatives command, the new version of Java (16 in this case) is highlighted

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 16, which you can tell by the 16 next to java at the beginning of the command. Type the number next to Java 16 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 16:

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

However, if you did not see the version of Java returned in that last command, feel free to reach out to our support team and we'll help you out with this! You can reach our support team by either opening a ticket on our website or our Discord.
Was this article helpful?
Thank you!