In our today’s guide, we are going to look at how to install Java 14 (OpenJDK 14) on Oracle Linux. What is java and what is it used for? Java is a programming language and a computing platform. You will find many powerful Enterprise applications written in Java. It is also required in our computers in order for some applications to run. Android applications are basically build with Java.

OpenJDK is the Java development environment. It is free to download and install. JDK 14 is the open-source reference implementation of version 14 of the Java SE Platform as specified by JSR 389.

Features of Java 14

A significant number of Java Enhancement Proposals (JEPs) have been released in version 14, ranging from the Java language support to the latest APIs for ongoing JDK flight recorder monitoring. Below are noted enhancements:

Option 1: Install OpenJDK 14 on Oracle Linux 8

Download OpenJDK 14 from JDK 14 release pages with the below commands.

sudo dnf -y install curl
curl -O https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_linux-x64_bin.tar.gz

Extract the downloaded OpenJDK 14 archive

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

Move the resulting folder to /opt directory.

sudo mv jdk-14.0.2 /opt/

Now let us configure Java environment.

sudo tee /etc/profile.d/jdk14.sh <<EOF
export JAVA_HOME=/opt/jdk-14.0.2
export PATH=\$PATH:\$JAVA_HOME/bin
EOF

Now Source the created Java profile file

source /etc/profile.d/jdk14.sh

Confirm installed Java version.

$ java -version
openjdk version “14.0.2” 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

Option 2: Install Java SE Development Kit 14 on Oracle Linux 8

If you wish to install Java SE Development Kit 14 instead, go ahead to download RPM package for Oracle Linux 8 from Oracle java download page. Download the rpm and install it by running the below commands:

sudo rpm -Uvh jdk-14.0.2_linux-x64_bin.rpm

Now confirm Java installed version.

$ java -version
java version “14.0.2” 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

Configure Java environment.

$ sudo tee /etc/profile.d/jdk14.sh <<EOF
export JAVA_HOME=/usr/java/default
export PATH=\$PATH:\$JAVA_HOME/bin
EOF

To use Java Home, source the file.

$ source /etc/profile.d/jdk14.sh

Test Java Installation.

To test our Java installation, let us create a simple html file. Create a file test.java with the content as shown below:

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

Compile Java code.

$ javac HelloWorld.java

Now run your java program.

$ java HelloWorld
Hello, world

Set default Java Version

Run the command below to choose your default java version.

$ sudo alternatives –config java

Key in the number for your chosen version and press Enter

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/java/jdk-14/bin/java

Enter to keep the current selection[+], or type selection number: 

Enjoy your java programming. Check more interesting guides below:

Java Courses to check:

$17.47
$174.66
in stock
Udemy.com
(10226)
$17.47
$174.66
in stock
Udemy.com
$16.30
$110.62
in stock
Udemy.com

LEAVE A REPLY

Please enter your comment!
Please enter your name here

eleven + fifteen =