Today, we are going to learn that how to install Oracle Java 14 on CentOS 8. As the Java 14 is released, you can read the new and interesting features by visiting official page.
It is used for various purposes like developing web applications, android applications, games development and much more. So, let’s move towards the installation of Java 14 on our CentOS system.
Here we’ll see the two methods to install Java 14 on CentOS 8 you can choose your preferred one for an easy installation.
Check out this
How to Install Java 14 on Ubuntu / Debian.
Step 1: Installing Java 14 on CentOS 8
Go to the official release page of JDK 14 for downloading the latest archive or use the below command to download it using the terminal.
sudo yum -y install curl
curl -O https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz
Output:
[sabi@localhost ~]$ curl -O https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 189M 100 189M 0 0 412k 0 0:07:50 0:07:50 --:--:-- 563k
Now, extract the above package
tar xvf openjdk-14_linux-x64_bin.tar.gz
Then move the output to the /opt/ directory
sudo mv jdk-14 /opt/
And set up the Java Environment variables.
[sabi@localhost ~]$ sudo tee /etc/profile.d/jdk14.sh <<EOF
> export JAVA_HOME=/opt/jdk-14
> export PATH=$PATH:$JAVA_HOME/bin
> EOF
export JAVA_HOME=/opt/jdk-14
export PATH=$PATH:$JAVA_HOME/bin
Now, source the file
source /etc/profile.d/jdk14.sh
Verify the installation using
$ echo $JAVA_HOME
/opt/jdk-14
$ java -version
openjdk version "14" 2020-03-30
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
Step 2: Installing Java SE Development Kit 14 on CentOS 8
As in one step we’ve installed the Java 14 using curl now we’ll install the Java SE Development Kit 14 on CentOS 8. For this you can go to the Java page and download the RPM package or by running the below command.
curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"https://download.oracle.com/otn-pub/java/jdk/14+36/076bab302c7b4508975440c56f6cc26a/jdk-14_linux-x64_bin.rpm"
Once, the package is downloaded, install it with the help of yum or rpm command.
$ sudo rpm -Uvh jdk-14_linux-x64_bin.rpm
warning: jdk-14_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying… (10################################# [100%]
Preparing… (10################################# [100%]
Updating / installing…
1:jdk-14-2000:14-ga ################################# [100%]
Verify the installation of Java 14 by running
java -version
java version "14" 2020-03-30
Java(TM) SE Runtime Environment (build 14+36-1461)
Java HotSpot(TM) 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
Now, set up the Java environment
cat <<EOF | sudo tee /etc/profile.d/jdk14.sh
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
EOF
Then source the file
source /etc/profile.d/jdk14.sh
Step 3: Set Java Version as Default Version
If you’ve installed multiple java version, you can configure them to choose which one is default.
sudo alternatives --config java
So, this is how you can install Java 14 on CentOS8.