Install Oracle Java 14 (OpenJDK 14) on CentOS 7/8 and Fedora 31/30/29

Ranch
You can support us by downloading this article in PDF format via the link below.

Download the guide as a PDF

turn off
Ranch

Ranch
Ranch

In today’s guide, we will discuss how to install Java 14 / OpenJDK 14 on CentOS 7/8 and Fedora 31/30/29. Java 14 is now available for general use-check out General release notes new function. Binaries are also available for production environments from: Oracle Applies to Java SE Development Kit 14.

JDK 14 is an open source reference implementation of the Java SE platform version 14. JSR 388 In the Java community process. Install the JDK | Follow these steps to use OpenJDK 14 on CentOS 8/7 and Fedora 31/30/29.

For Ubuntu / Debian, use: Install Oracle Java 14 (OpenJDK 14) on Ubuntu & Debian

Option 1: Install OpenJDK 14 on CentOS 8/7 and Fedora 31-28

Visit JDK 14 release page Download the latest file.

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

Use the tar command to decompress the downloaded OpenJDK 14 archive.

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

Move the results folder to the / opt directory.

sudo mv jdk-14 /opt/

Configure the Java environment:

sudo tee /etc/profile.d/jdk14.sh <

Get your profile and check java command

source /etc/profile.d/jdk14.sh

Confirm the Java version.

$ 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)

Option 2: Install Java SE Development Kit 14 on CentOS 8/7 and Fedora 31-29

If you choose to Java SE development kitOne4Please use the following command to download the RPM package for CentOS / RHEL / Fedora system.

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"

Then use the yum or rpm command to install the RPM package.

$ 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%]

Confirm that Java version is installed

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

Configure the Java environment.

cat <

To use Java Home, provide a file source.

source /etc/profile.d/jdk14.sh

Test Java installation

Create a HelloWorld Java program.

$ vi HelloWorld.java 
public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }

}

Compile the Java code.

$ javac HelloWorld.java

Run your Java program.

$ java HelloWorld
Hello, World

Select the default version of Java

If multiple Java versions are installed, you can use the Alternatives command to set the default version.

sudo alternatives --config java

Select Java as the default.

$ sudo alternatives --config java

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: 

Recommended books:

The best Java development books

Enjoy Java development on Linux machines and check out other related guides in our blog.

Install Node.js on CentOS 8

Install Ruby on CentOS 8

Ranch
You can support us by downloading this article in PDF format via the link below.

Download the guide as a PDF

turn off
Ranch

Ranch
Ranch

Related Posts