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 :
Installed: java-11-openjdk-1:184.108.40.206-0.el8_2.x86_64 java-11-openjdk-devel-1:220.127.116.11-0.el8_2.x86_64 java-11-openjdk-headless-1:18.104.22.168-0.el8_2.x86_64 Complete!
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)
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-22.214.171.1242.b10-0.el8_2.x86_64/jre/bin/java) 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-126.96.36.199-0.el8_2.x86_64/bin/java) Enter to keep the current selection[+], or type selection number: 2
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.