Install Java on Ubuntu 20.04

Java 11 is the latest LTS release available for installation. The default Ubuntu packages repositories contain the packages for the OpenJDK 11. The default repository also contains OpenJDK 8 previous stable release packages. The JDK packages provide the full Java development libraries, helpful for the development systems. To run any Java application, you just needed a Java runtime environment (JRE).

1. Install Java 11 on Ubuntu

Run the below command to install OpenJDK 11 package on your system. Once the installation is complete, you can verify it by checking the Java version: OpenJDK 11 has been installed. Continue to install OpenJDK 8.

2. Install Java 8 on Ubuntu

Java 8 is the previous stable release, Most of the java-based applications works on it. Run the below command to install OpenJDK 8 package on your system. Once the installation is complete, you can verify it by checking the Java version: All done, you have successfully installed Java (OpenJDK) on your Ubuntu system.

3. Install Oracle Java 14

Oracle Java 14 is available to download and install without getting a commercial license. You can visit official download page to download Debian file on your system. Also, you can use the below command to download the Debian file using the command line. If the above command does not work or you found a file not found error, please go to the official download page. Check for the current version and download it to your system. Once you download the Debian file, install it on your system using command below: The above command installs Oracle Java 14 on your system. All the files will be placed under /usr/lib/jvm directory. Now set an alternative reference to newly installed Java on your system. Oracle Java 14 has been installed on your Ubuntu system. You can use the next step to switch between multiple Java versions on your system.

Switch Between Multiple Java Versions

Most of the Unix/Linux-based systems allow to the installation of multiple Java versions on one system. If you also have multiple Java versions installed on your system. You can change to the default java version as per your requirements. The update-alternatives provides you option to maintain symbolic links for the default commands. To change default Java version run command on terminal: This will show the list of all java binaries installed on your system. Enter a number to select the default Java version and press enter. See the below screenshot:

The above command will change the Default Java version on your system by changing the link references to java binary. Now, again run command java -version to view the default Java version.


In this tutorial, you have learned about the installation of multiple Java on the Ubuntu 20.04 systems. Also found a solution to change the default Java version via the command line.

How to Install Java on Ubuntu 20 04   TecAdmin - 51