Java is a fundamental programming language and platform that many applications rely on. If you're using Ubuntu 20.04 and need to run or develop Java applications, you'll need to install the appropriate Java packages. This guide will walk you through installing Java using the OpenJDK implementation.

Installing Java on Ubuntu 20.04

OpenJDK 11 is the version available in the Ubuntu 20.04 repositories. It provides the Java Runtime Environment (JRE) for running Java applications and the Java Development Kit (JDK) for developing them.

Step 1: To install the Java Runtime Environment, open your terminal and execute the following command:

sudo apt install openjdk-11-jre

This command installs the openjdk-11-jre package, enabling your system to run Java applications.

Step 2: If you plan to develop Java applications, install the Java Development Kit by running:

sudo apt install openjdk-11-jdk

The openjdk-11-jdk package includes the JRE and adds the necessary development tools.

Step 3: To explore additional packages related to OpenJDK 11, such as documentation or debugging tools, use the following command:

apt search openjdk-11

This will display a list of all related packages available in the repositories.

Verifying the Installation

After installing Java, it's important to verify that it was installed successfully.

Step 1: Check the installed version of the Java Runtime Environment by running:

java --version

You should see output indicating the version of Java installed on your system.

Step 2: To confirm that the Java Development Kit is installed, execute:

javac --version

The javac command represents the Java compiler, which is essential for Java development.

The output will display the version of the Java compiler, confirming the JDK installation.


With Java installed and verified, you're now ready to run Java applications and develop your own on your Ubuntu 20.04 system.