How to Install Java 14 on Linux, Ubuntu, CentOS With Examples

Java 14 is released on March 2020. In this tutorial, we will learn how to Install Java 14 on Linux. We will learn two ways to install Java on Linux.

  1. Using Package Manager – apt (Debian Based) and yum (RPM Based)
  2. Manual way – works on all Linux distributions

Install Java 14 on Debian, Ubuntu using apt package manager

The apt package manager is very powerful. If you run a command and if it’s not present, it automatically gives you a suggestion on how to install it.

Let’s run java -version command on our Ubuntu 20.04 LTS server.

Since we require only JRE to run the java command, it’s giving us the command to install the latest JRE versions.

But, if you want to run jshellor javac commands, then you need JDK 14.

Based on the above commands output, the following commands can be used to install JRE 14 and JDK 14 in Debian systems using apt command.

Install JRE 14 on Debian, Ubuntu:

Install JDK 14 on Debian, Ubuntu:

After executing above commands, you can verify the java version.

Read Next: Java 14 Features

Installing Java 14 on Linux Manually

I personally like to install Java manually, it gives me easy way to upgrade and switch to another java version quickly.

Let’s learn how to install Java 14 on Linux machines manually. This will work on any Linux distributions, whether Deb or RPM based.

Step 1: Download the JDK 14 Build

Go to the JDK 14 GA Release Page and copy the Linux build link.

jdk-14-linux-build-urlJdk 14 Linux Build Url

Then use the wget or curl command to download it in your Linux system.

After downloading is finished, untar it.

Let’s go inside the JDK bin directory and run the java command.

I am using the same system where we installed the JDK 14 using the apt package manager. Let’s see the location of “java” command and the PATH variable.

So, if you already have another Java version installed, then it’s essential to add the new JDK location in front of the PATH variable. So that when we run java commands, our directory will be searched first and java command will be found and executed.

Open the user profile (.bashrc or .bash_profile or .profile) and add the following lines to it.

Then save and exit the file. Let’s run the source command to reload the user profile settings.

Now, let’s check the PATH variable and java command output.

The which java command will tell us that the it’s using the java command from our JDK 14 directory.

Installing Java 14 on CentOS, RPM Based Linux Systems

Let’s use yum list command to see if OpenJDK 14 is available on yum repository or not.

As it turned out, YUM repositories have only LTS releases of JDK. The last two LTS releases are JDK 11 and JDK 8.

So, if you want to install Java 14 on CentOS or other RPM based Linux machines, use the manual way.

Just download the JDK build, untar it, and configure the PATH variable.

Conclusion

It’s very easy to install Java on Linux systems. The Debian based distributions are very active and they have the latest JDK 14 and JRE 14 builds on APT repository. If you are on RPM based Linux machine, then either use the LTS releases or install the Java 14 manually.

By admin

Leave a Reply

%d bloggers like this: