• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Java on Ubuntu 20.04

Written by Rahul, Updated on July 4, 2020

Java is the most popular object oriented, robust, platform independent programming language. There are multiple applications required for your system required Java on your system. This guide will help you to install Java (OpenJDK 11 and OpenJDK 8) stable releases or Oracle Java 14 on your Ubuntu 20.04 LTS (Focal Fossa) system. You will also find the instruction’s to switch between multiple installed Java versions.

Install Java on Ubuntu 20.04

The Java 11 is the latest LTS release available for the installation. The default Ubuntu packages repositories contains the packages for the OpenJDK 11. The default repository also contains OpenJDK 8 previous stable release packages.

The JDK packages provides the full Java development libraries, helpful for the development systems. To run any Java application, you just needed Java runtime environment (JRE).

1. Install OpenJDK 11

Run the below command to install OpenJDK 11 package on your system.

sudo apt update
sudo apt install openjdk-11-jdk

Once the installation is complete, you can verify it by checking the Java version:

java -version

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

OpenJDK 11 has been installed. Continue to install OpenJDK 8.

2. Install OpenJDK 8

Java 8 is the previous stable release, Most of the java-based application’s works on it. Run the below command to install OpenJDK 8 package on your system.

sudo apt update
sudo apt install openjdk-8-jdk

Once the installation is complete, you can verify it by checking the Java version:

java -version

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

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 commercial license. You can visit official download page to download debian file on your system. Also, you can use the below command to download debian file using command line.

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_linux-x64_bin.deb"

If above command does not work or you found file not found error, please go to official download page. Check for the current version and download on your system.

Once you download the Debian file, install it on your system using command below:

sudo dpkg -i jdk-14.0.1_linux-x64_bin.deb

The above command install Oracle java 15 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.

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-14.0.1/bin/java 100

Oracle java 14 has been installed on your Ubuntu system. You can use next step to switch between multiple java versions on your system.

Switch Between Multiple Java Versions

Most of the Unix/Linux based systems allows to install multiple Java versions on one system. If you also have multiple Java versions installed on your system. You can change to 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:

update-alternatives --config java

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:

How to Switch between Java versions on Ubuntu 20.04

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.

java -version

java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

Conclusion

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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

2 Comments

  1. Avatar Jesse Kang'arua Reply
    January 10, 2021 at 1:32 pm

    Thanks so much for this post, it really helped me install multiple jvm. Cheers and keep up the good work

  2. Avatar Naamadevan Reply
    May 12, 2020 at 6:03 am

    very nice bro

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • How to Install Python 3.9 on CentOS/RHEL 8
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Install PyCharm on Ubuntu 20.04
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy