December 3, 2021
How to install java openJDK

How To Install Java (OpenJDK 11) On CentOS 8

Java is a open-source and general-purpose programming language which is designed to have as few implementation dependencies as possible. Java is is class-based, object-oriented programming intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform. Beside OpenJDK, there is an Oracle Java, which has some additional commercial features. On this article we will learn how to install OpenJDK 11 on CentOS 8 operating system.

OpenJDK 11 Installation On CentOS 8

We will be briefly discussing how to install OpenJDK 11 on Centos 8 operating system. There are will be several steps as explained below.


Before we are going to install OpenJDK on Centos 8, there are several prerequisite to be fulfilled, namely : root account or ordinary account with sudo privilege, sufficient disk space, good internet connection.


To install the OpenJDK 11 on CentOS 8, we will use the dnf command line as root or user with sudo privileges.

[ramans@otodiginet ~]$ sudo dnf install java-11-openjdk-devel

output well be :


install openJDK 11 on CentOS 8

After the installation was completed done, then we will verify the installation with querying its version, use the command line below.

[ramans@otodiginet ~]$ java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
java -version

The query result of java version is showing if the Java version is 1.8.0 not version 11.14. This happens because our system already has java version 1.8. We will check all java installed on our system.

Setting Default Java Version

If we have installed multiple Java versions on our system, we can use the alternatives system to set which Java version will be used when we type java in the terminal. The command line to be used is as follow.

[ramans@otodiginet ~]$ sudo alternatives --config java

The output will be as below.

There are 2 programs which provide 'java'.

Selection Command
*+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-
2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-

Enter to keep the current selection[+], or type selection number: 2
Setting Default Java Version

On the screenshot above, we have chosen the number 2, to switch to Java 11 openjdk. Then we verify again the current Java used on our system by submitting java –version command line again.

[ramans@otodiginet ~]$ java -version
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)


So far, the OpenJDK 11 installation on CentOS 8 has been completed done, you also could discover this link for OpenJDK 11 installation on Ubuntu 20.04 LTS.

Share this article via :

9 thoughts on “How To Install Java (OpenJDK 11) On CentOS 8

Leave a Reply

Your email address will not be published. Required fields are marked *