In this article we will discuss a procedure on how to install OpenJDK java on Ubuntu 20.04 LTS Focal Fossa Linux.
Follow our tutorial on how to install Oracle Java on Ubuntu 20.04 Focal Fossa.
In this tutorial you will learn:
- How to install OpenJDK Java
- How to switch between Java versions
- How to check java version
Software Requirements and Conventions Used
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 the standard Ubuntu repository.
- 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
- 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
- Confirm installation:
At this stage thejava
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.
- Switch between installed versions:
To switch between version execute the following two commands while selecting the Java version you require:
$ sudo update-alternatives --config java $ sudo update-alternatives --config javac