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.
- Using Package Manager – apt (Debian Based) and yum (RPM Based)
- Manual way – works on all Linux distributions
Table of Contents
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.
root@localhost:~# cat /etc/os-release | grep VERSION VERSION="20.04 LTS (Focal Fossa)" VERSION_ID="20.04" VERSION_CODENAME=focal root@localhost:~# root@localhost:~# java -version Command 'java' not found, but can be installed with: apt install default-jre # version 2:1.11-72, or apt install openjdk-11-jre-headless # version 11.0.7+10-3ubuntu1 apt install openjdk-8-jre-headless # version 8u252-b09-1ubuntu1 apt install openjdk-13-jre-headless # version 13.0.3+3-1ubuntu2 apt install openjdk-14-jre-headless # version 14.0.1+7-1ubuntu1 root@localhost:~#
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 jshell
or javac
commands, then you need JDK 14.
root@localhost:~# jshell Command 'jshell' not found, but can be installed with: apt install openjdk-11-jdk-headless # version 11.0.7+10-3ubuntu1, or apt install openjdk-13-jdk-headless # version 13.0.3+3-1ubuntu2 apt install openjdk-14-jdk-headless # version 14.0.1+7-1ubuntu1 root@localhost:~# javac -version Command 'javac' not found, but can be installed with: apt install default-jdk # version 2:1.11-72, or apt install openjdk-11-jdk-headless # version 11.0.7+10-3ubuntu1 apt install ecj # version 3.16.0-1 apt install openjdk-8-jdk-headless # version 8u252-b09-1ubuntu1 apt install openjdk-13-jdk-headless # version 13.0.3+3-1ubuntu2 apt install openjdk-14-jdk-headless # version 14.0.1+7-1ubuntu1 root@localhost:~#
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:
root@localhost:~# apt install openjdk-14-jre-headless
Install JDK 14 on Debian, Ubuntu:
root@localhost:~# apt install openjdk-14-jdk-headless
After executing above commands, you can verify the java version.
root@localhost:~# javac -version javac 14.0.1 root@localhost:~#
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.

Then use the wget or curl command to download it in your Linux system.
root@localhost:~# wget https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_linux-x64_bin.tar.gz OR root@localhost:~# curl -O https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_linux-x64_bin.tar.gz
After downloading is finished, untar it.
root@localhost:~# tar -xvf openjdk-14.0.1_linux-x64_bin.tar.gz
Let’s go inside the JDK bin directory and run the java command.
root@localhost:~# cd jdk-14.0.1/bin/ root@localhost:~/jdk-14.0.1/bin# ./java -version openjdk version "14.0.1" 2020-04-14 OpenJDK Runtime Environment (build 14.0.1+7) OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing) root@localhost:~/jdk-14.0.1/bin#
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.
root@localhost:~# which javac /usr/bin/javac root@localhost:~# root@localhost:~# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin root@localhost:~#
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.
PATH="/root/jdk-14.0.1/bin:$PATH" export PATH
Then save and exit the file. Let’s run the source command to reload the user profile settings.
root@localhost:~# source .bashrc
Now, let’s check the PATH variable and java command output.
root@localhost:~# echo $PATH /root/jdk-14.0.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin root@localhost:~# root@localhost:~# java -version openjdk version "14.0.1" 2020-04-14 OpenJDK Runtime Environment (build 14.0.1+7) OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing) root@localhost:~#
The which java
command will tell us that the it’s using the java command from our JDK 14 directory.
root@localhost:~# which java /root/jdk-14.0.1/bin/java root@localhost:~#
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.
[root@centos /]# yum list "*openjdk*" Available Packages java-1.8.0-openjdk.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-demo.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-devel.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-headless.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.252.b09-2.el8_1 AppStream java-1.8.0-openjdk-src.x86_64 1:1.8.0.252.b09-2.el8_1 AppStream java-11-openjdk.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-demo.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-devel.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-headless.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-javadoc.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-javadoc-zip.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-jmods.x86_64 1:11.0.7.10-1.el8_1 AppStream java-11-openjdk-src.x86_64 1:11.0.7.10-1.el8_1 AppStream [root@centos /]#
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.