In this short guidance, we will guide you through how to install OpenJDK 11 on CentOS 8 operating system. 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.
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.
OpenJDK 11 Installation on CentOS 8
To install OpenJDK 11 on CentOS 8 is a simple step. OpenJDK 11 installation will be consist of several steps, the detailed steps will be explained below.
1. Prerequisite
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
2. Installing OpenJDK 11 on CentOS
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 ================================================================================ Installing: java-11-openjdk-devel x86_64 1:11.0.8.10-0.el8_2 AppStream 3.4 M Installing dependencies: java-11-openjdk x86_64 1:11.0.8.10-0.el8_2 AppStream 249 k java-11-openjdk-headless x86_64 1:11.0.8.10-0.el8_2 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-11.0.8.10-0.el8_2.x86_64 79 kB/s | 249 kB 00:03 (2/3): java-11-openjdk-devel-11.0.8.10-0.el8_2. 681 kB/s | 3.4 MB 00:05 (3/3): java-11-openjdk-headless-11.0.8.10-0.el8 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:11.0.8.10-0.el8_2.x86_64 1/1 Preparing : 1/1 Installing : java-11-openjdk-headless-1:11.0.8.10-0.el8_2.x86_64 1/3 Running scriptlet: java-11-openjdk-headless-1:11.0.8.10-0.el8_2.x86_64 1/3 Installing : java-11-openjdk-1:11.0.8.10-0.el8_2.x86_64 2/3 Running scriptlet: java-11-openjdk-1:11.0.8.10-0.el8_2.x86_64 2/3 Installing : java-11-openjdk-devel-1:11.0.8.10-0.el8_2.x86_64 3/3 Running scriptlet: java-11-openjdk-devel-1:11.0.8.10-0.el8_2.x86_64 3/3 Running scriptlet: java-11-openjdk-1:11.0.8.10-0.el8_2.x86_64 3/3 Running scriptlet: java-11-openjdk-devel-1:11.0.8.10-0.el8_2.x86_64 3/3 Verifying : java-11-openjdk-1:11.0.8.10-0.el8_2.x86_64 1/3 Verifying : java-11-openjdk-devel-1:11.0.8.10-0.el8_2.x86_64 2/3 Verifying : java-11-openjdk-headless-1:11.0.8.10-0.el8_2.x86_64 3/3 Installed products updated. Installed: java-11-openjdk-1:11.0.8.10-0.el8_2.x86_64 java-11-openjdk-devel-1:11.0.8.10-0.el8_2.x86_64 java-11-openjdk-headless-1:11.0.8.10-0.el8_2.x86_64 Complete!
3. 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)
4. 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
Output :
[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-1.8.0.262.b10-0.el8_2.x86_64/jre/bin/java) 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64/bin/java) 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)
Conclusion
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.