9.5 C
Tuesday, January 19, 2021

How to install Java on RHEL 8 / CentOS 8 / Oracle Linux 8 ?

Must read

Please Donate

Senior Writer and partner

Java is one of the most popular programming languages out there. This is because it is the basis of many vital technologies in the professional field such as Jenkins or Tomcat. In this context, it is always convenient to have it in our operating systems. Therefore, in this post, we will teach you how to install Java on RHEL 8, CentOS 8 and Oracle Linux 8.

OpenJDK vs Oracle Java

Java is open source but its property belongs to Oracle. So, the community, taking advantage that Java is open source, has made a free oracle implementation called OpenJDK. Both do their job but there is more professional support if you use the Oracle version.

So today I will show you how to install both versions of Java on RHEL, CentOS and Oracle Linux 8.

1) Install Java (OpenJDK) on RHEL, CentOS and Oracle Linux 8

In the official distribution repositories, there are two versions of OpenJDK based on Java 8 and Java 11. Choose the one that best suits your needs or simply install both.

For OpenJDK Java 8:

:~$ su
:~# dnf install java-1.8.0-openjdk-devel

But, if you want to install version 11.

:~# dnf install java-11-openjdk-devel

And that is it.

2) Install Oracle Java on RHEL, CentOS and Oracle Linux 8

Downloading the Oracle version on a server is a bit more complicated because for version 11 which is the last LTS, Log in is required. Then, you have to download it on another computer and upload it via FTP to the server.

Once you have done this, install it with the following command:

:~# dnf install [file_path]

On the same Oracle download site, you will be able to choose several versions of Java. However, keep in mind that 11 is the last LTS and is the safest.

3) Set the default Java version

Sometimes it’s a good idea to have several versions of Java installed. This is because there are many programs that although they are created with Java, they know how to make better use of one version than the other.

Then, you have to tell the system which is the default version that the operating system will take. Of course, you can change versions without any problem.

To do this, in the terminal run the following:

:~# alternatives --config java

And write the number corresponding to the Java version you want to leave by default.

1.- Java on RHEL CentOS and Oracle Linux 8
1.- Java on RHEL CentOS and Oracle Linux 8

Next, check the version Java.

:~# java --version
openjdk 11.0.2 2019-01-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.2+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode, sharing)

And that is it. Enjoy it.


Installing Java on a current operating system is quite easy and necessary. Especially if it is an application server that must be able to run multiple different applications. Today in this post, we have installed Java on RHEL CentOS and Oracle Linux 8.

Please share this post with your friends and join our Telegram channel.

More articles


Please enter your comment!
Please enter your name here


Latest article