Java is a programming language and computing language platform. Java 14 is the open-source reference implementation of version 14 of the Java SE Platform as specified by JSR 388 in the Java community process. JDK is a collection of various programming tools among them are; JRE (Java Runtime Environment), Java, Javac, Jar e.t.c

Java 14 has many features among them are:

  • Pattern Matching for instance-of(preview)
  • None-volatile mapped Byte Buffers.
  • Foreign-Memory Access API
  • Text Blocks(second Preview)
  • NUMA-Aware Memory Allocation for G1.
  • JFR Event Streaming.
  • Helpful NullpointerExceptions
  • Deprecate the Solaris and SPARC ports
  • ZGC on Windoows.
  • Remove the Pack200 Tools and API.
  • JRF Event Streaming.

This article demonstrates how to install Java 14 (OpenJDK 14) on Rocky Linux 8.

How To Install Java 14 on Rocky Linux 8

We will cover a few ways of how to get Java 14(OpenJDK 14) installed on Rocky Linux 8.

  1. OpenJDK
  2. Oracle JDK/JRE

1. Install OpenJDK 14 on Rocky Linux 8

Java Development Kit 14(JDK) is the open source reference implementation of version 14 of the Java SE platform. OpenJDK is available from RHEL 8 for x86_64 – AppStream (RPMs),but the available versions are not up-to-date.To download the Open-source JDK 14 use Wget as below.. If you do not have wget, install it using sudo yum install wget and also install curl sudo yum -y install curl

curl -O https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz

Sample output

Then extract the package

tar xvf openjdk-14_linux-x64_bin.tar.gz

Move the extracted file to the /opt/ directory as below.

sudo mv jdk-14 /opt/

Set the Java Environment variables as below.

export JAVA_HOME=/opt/jdk-14
export PATH=$PATH:$JAVA_HOME/bin 

Verify your Java installation

$ echo $JAVA_HOME
 /opt/jdk-14
$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

2. Install Oracle JDK 14 on Rocky Linux 8

This is achieved by downloading the production-ready OpenJDK 14 from the Java SE Downloads page or use wget as below. Remember login is required upon visiting the official page. After login, you can obtain your download URL and use as below

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" *Download URL*

Install the .rpm file.

sudo rpm -ivh jdk-14*_linux-x64_bin.rpm

Sample output.

warning: jdk-14.0.2_linux-x64_bin1.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-14.0.2-2000:14.0.2-ga        ################################# [100%]

By default, java is installed in /usr/java/ directory. However you can install in a custom path using sudo rpm -ivh –prefix=// .rpmfile

Set the Default Java Version on Rocky Linux 8.

With Multiple Java versions installed on Rocky Linux 8. You can set the default one as below.

First list the available versions

sudo alternatives --config java

Sample output if your system has multiple versions you will see this.

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1        java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-2.el          
   2           /usr/java/jdk-14.0.2/bin/java
Enter to keep the current selection[+], or type selection number: 2

Select your version by typing the number as above

Verify the Java 14 installation on Rocky Linux 8

With the default version set, go ahead and verify the version using:

$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

Test Java Installation

Let us now test the installed Java by creating a simple html file with the below content.

sudo vi HelloWorld.java 

In the file paste this

public class test {
	public static  void main(String[] args) {
	System.out.println(“Hello, world”);
	}
}

Compile the Code.

sudo javac HelloWorld.java

Sample output.

$ java HelloWorld
Hello, World

Video Courses to Learn Java Programming Language:

Conclusion

The article demonstrates how to install Java 14 (OpenJDK 14) on Rocky Linux 8. We have seen the two ways to get Java 14 installed on Rocky Linux 8, configuring and setting the default Java version. I hope this article was useful.

Find related articles on our website.

How To Install Java 8 (OpenJDK 8) on Oracle Linux 8

Install Java 14 (OpenJDK 14) on Oracle Linux 8

Install Java / OpenJDK on Linux Mint

LEAVE A REPLY

Please enter your comment!
Please enter your name here