In this article we will discuss a procedure on how to install OpenJDK java on Ubuntu 20.04 LTS Focal Fossa Linux.

In this tutorial you will learn:
  • How to install OpenJDK Java
  • How to switch between Java versions
  • How to check java version
 Java on Ubuntu 20.04 LTS Focal Fossa
Java on Ubuntu 20.04 LTS Focal Fossa

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 20.04 LTS Focal Fossa
Software OpenJDK 8,11,13,14 and OracleJDK 12,13
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to install OpenJDK Java on Ubuntu 20.04 LTS Focal Fossa step by step instructions

By default the Ubuntu 20.04 LTS Focal Fossa Linux offers multiple versions of Java OpenJDK. For example the OpenJDK versions 8,11,13 and 14 are available from a standard Ubuntu repository.

  1. Search for available OpenJDK versions:

    Unless you already know which version of OpenJDK you wish to install, then as a first step perform a search of all available packages:
    $ apt search openjdk
    

  2. SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  3. Install OpenJDK:

    Once ready, install any of the available OpenJDK java versions. For example:
    $ sudo apt install openjdk-8-jdk
    OR
    $ sudo apt install openjdk-11-jdk
    OR
    $ sudo apt install openjdk-13-jdk
    OR
    $ sudo apt install openjdk-14-jdk
    
  4. Confirm installation:

    At this stage the java command should be available on your system and return your installed version:
    $ java --version
    openjdk 14-ea 2020-03-17
    OpenJDK Runtime Environment (build 14-ea+18-Ubuntu-1)
    OpenJDK 64-Bit Server VM (build 14-ea+18-Ubuntu-1, mixed mode, sharing)
    
    Additionally test your java installation by compiling Java Hello World program.
  5. Switch between installed versions:

    To switch between version execute the following two command while selecting the Java version you require:
    $ sudo update-alternatives --config java
    $ sudo update-alternatives --config javac
    
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.