How to Install Java (Open JDK 11) on CentOS 8

Currently, almost all applications that run on all devices must use Java as the framework. Ranging from mobile applications to enterprise applications. Java is an open-source and general-purpose programming language which is designed to have as few implementation dependencies as possible. This guide is intended for help beginners installing Open JDK 11 on CentOS 8 operating system.


ava 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.


Before we are going to install OpenJDK on Centos 8, there are several prerequisite to be fulfilled, namely :

  • a CentOS 8 server
  • user account with sudo privilege
  • sufficient disk space and good internet connection

OpenJDK 11 Installation

1. Install OpenJDK 11

To install OpenJDK 11 on CentOS 8 is a simple step. We just enter a simple command line then verify it by showing its version.

$ sudo dnf install java-11-openjdk-devel

The output will be as shown below :

[ramans@bckinfo ~]$ sudo dnf install java-11-openjdk-devel
Extra Packages for Enterprise Linux 8 - x86_64  9.0 kB/s |  18 kB     00:02    
Extra Packages for Enterprise Linux 8 - x86_64  181 kB/s | 7.5 MB     00:42    
MySQL 8.0 Community Server                      960  B/s | 2.5 kB     00:02    
MySQL Connectors Community                      2.9 kB/s | 2.5 kB     00:00    
MySQL Tools Community                           3.3 kB/s | 2.5 kB     00:00    
Oracle Linux / RHEL / CentOS-8 / x86_64 - Virtu 103  B/s | 181  B     00:01    
Dependencies resolved.
 Package                    Arch     Version                  Repository   Size
 java-11-openjdk-devel      x86_64   1:      AppStream   3.4 M
Installing dependencies:
 java-11-openjdk            x86_64   1:      AppStream   249 k
 java-11-openjdk-headless   x86_64   1:      AppStream    40 M

Transaction Summary
Install  3 Packages

Total download size: 43 M
Installed size: 177 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): java-11-openjdk-  79 kB/s | 249 kB     00:03    
(2/3): java-11-openjdk-devel- 681 kB/s | 3.4 MB     00:05    
(3/3): java-11-openjdk-headless- 1.9 MB/s |  40 MB     00:20    
Total                                           2.0 MB/s |  43 MB     00:21     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: java-11-openjdk-headless-1:    1/1 
  Preparing        :                                                        1/1 
  Installing       : java-11-openjdk-headless-1:    1/3 
  Running scriptlet: java-11-openjdk-headless-1:    1/3 
  Installing       : java-11-openjdk-1:             2/3 
  Running scriptlet: java-11-openjdk-1:             2/3 
  Installing       : java-11-openjdk-devel-1:       3/3 
  Running scriptlet: java-11-openjdk-devel-1:       3/3 
  Running scriptlet: java-11-openjdk-1:             3/3 
  Running scriptlet: java-11-openjdk-devel-1:       3/3 
  Verifying        : java-11-openjdk-1:             1/3 
  Verifying        : java-11-openjdk-devel-1:       2/3 
  Verifying        : java-11-openjdk-headless-1:    3/3 
Installed products updated.



2. Verifying Java Installation

To verity Java which was already installed, we just display its version by submitting command line :

$ java -version

The output will be shown below :

[ramans@bckinfo ~]$ 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)

3. Switch To Another Java Version

If there were already another version of java in the system then we can switch to another version using the command line :

$ sudo alternatives --config java

The output will be shown below :

[ramans@bckinfo ~]$ sudo alternatives --config java
[sudo] password for ramans: 

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
[ramans@bckinfo ~]$ 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)
[ramans@bckinfo ~]$ 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)


On this guide, we have tried to install Java 11 (OpenJDK 11) on the CentOS8 operating system. Hopefully this article is useful for friends in need.


Add a Comment

Your email address will not be published.