In this article, We are going to perform How to Download and Install Oracle JAVA 11 on CentOS 8 Manually or any other cloud platform like Amazon EC2, Azure VM, Google Cloud Compute,etc. with preinstalled CentOS 8.
Java is a set of software and specifications developed at Sun Microsystems. There are two tyes of Java Platforms are JDK (Java Development Kit) and JRE (Java Runtime Environment). Both are helpful for deploying applications on servers and debugging, JVM monitoring,developing.
Oracle Java 8 has ended support in January 2019, You should upgrade to latest version.
- CentOS 8 with Minimal Installation
- SSH access with sudo privileges
To check CentOS version:
$ uname -a
$ cat /etc/os-release
NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8"
Follow the below steps to Install Oracle Java 11 on CentOS 8 Manually using command line.
Step 1: Download Oracle Java 11
Generally Oracle will not allow to download directly without accepting their licences. We have to create one account in Oracle java website by your personal or official mail. After accepting licence download the application from browser to local machine.
This link takes you to the Oracle home website Oracel Java SRE.
Once you opened above link goto “Java SE Development Kit 11.0.6” section, click on “Accept License Agreement” Radio button and download “jdk-11.0.6_linux-x64_bin.tar.gz” setup for Linux.
After downloading into local machine, using SCP/SFTP/FTP transfer the file from local machine to CentOS server.
Step 2: Copy downloaded Setup and Extract
Create a directory /opt/jdk
$ sudo mkdir -p /opt/jdk
Copy the tar file from the directory copied from local machine to server to /opt/jdk folder and execute below command:
$ sudo cp -rf /home/fosstechnix/jdk-11.0.6_linux-x64_bin.tar.gz /opt/jdk/$ cd /opt/jdk/$ sudo sudo tar -zxf jdk-11.0.6_linux-x64_bin.tar.gz
Now unarchived the file and check the content by long-list:
$ ls jdk-11.0.6 jdk-11.0.6_linux-x64_bin.tar.gz
Step 3: Install Oracle Java 11 on CentOS 8 with Alternatives
Use update-alternatives command to configure java on your system
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk-11.0.6/bin/java 100
After executing above command it shows below output:
update-alternatives: using /opt/jdk/jdk-11.0.6/bin/java to provide /usr/bin/java (java) in auto mode
Note : Its not particularly o/p if you have installed open jdk before
Step 4: Verify Update Alternatives
Enter below command shows output:
$ sudo update-alternatives --display java
java - status is auto. link currently points to /opt/jdk/jdk-11.0.6/bin/java /opt/jdk/jdk-11.0.6/bin/java - priority 100 Current `best' version is /opt/jdk/jdk-11.0.6/bin/java.
To change for alternative mode:
$ sudo update-alternatives --config java
Here In my system, I am configuring Java 11 first time, if you had installed any previous version of java it shows options like 0,1,2 to set default version of Java.
There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /opt/jdk/jdk-11.0.6/bin/java Enter to keep the current selection[+], or type selection number: 1
Step 5: Setting the JAVA_HOME Environment Variables
To define the environment variable:
$ sudo nano /etc/environment
Paste the below variable on the file:
To check variables defined:
$ source /etc/environment
$ echo $JAVA_HOME
Update the System packages
$ sudo yum update
Step 6: Verify Java Version
To check the java version:
$ java -version
java version "11.0.6" 2020-01-14 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)
If you seeing output like above then we have successfully downloaded and installed oracle Java 11 on CentOS 8 Manually.
In this article, We have covered install oracle java 11 on CentOS 8,downloaded Oracle Java 8 from official site, installed using command line, configured JAVA_HOME ,checked to switch java version and checked installed java version using command line.