Java openJDK 8 / 11
Install on Linux (Ubuntu/Lubuntu)

Addet at:Mon, Mar 15, 2021 Updated at:Sun, Sep 15, 2024

In this article I briefly describe how you can install Java openJDK version 8 or 11 on a Linux system (Ubuntu/Lubuntu). This guide is also applicable to other Linux distributions. It is a step-by-step installation guide for beginners.

Advance info - what you should know before

The prerequisite for an error-free Java installation is that either Java is not yet installed on your system, or the current Java version is installed without errors. This means that there is no faulty Java installation on your system that needs to be uninstalled first. If there is, then it cannot be guaranteed that this Java installation will work without errors.

Experience shows that it is quicker and easier to reset a system to a "clean" state than to invest a long time in troubleshooting and debugging a faulty Java installation. A new Linux installation takes about 20 minutes and is almost fully automatic. Therefore, in most cases, a long time of troubleshooting and debugging is less useful.

Java openJDK - Install under Linux via terminal

1. System Update / Upgrade run through

First, perform a system update and upgrade using the following commands in the terminal.

$ sudo apt update
$ sudo apt upgrade

2. Checks if Java is already installed

A Java version may already be installed. You can now check this with this command in the terminal.

$ java -version

If a Java version is already installed, the following output will appear depending on the version.

openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

If Java is not installed, the following output will appear.

Command 'java' not found, but can be installed with:

sudo apt install openjdk-11-jre-headless  # version 11.0.9.1+1-0ubuntu1~20.04, or
sudo apt install default-jre              # version 2:1.11-72
sudo apt install openjdk-8-jre-headless   # version 8u275-b01-0ubuntu1~20.04
sudo apt install openjdk-13-jre-headless  # version 13.0.4+8-1~20.04
sudo apt install openjdk-14-jre-headless  # version 14.0.2+12-1~20.04

If this message does not appear, then run "update and upgrade" from point 1 and repeat this step.

2. Java 11 installieren

Java version 11 is now installed. The installation process for version 8 is identical. Version 11 can be installed over version 8 at any time.

Now run this command in the terminal to install Java version 11 on your Linux system.

$ sudo apt install openjdk-11-jre-headless

Java should now have been installed successfully. To check, you can use this command in the terminal.

$ java -version

Done, Java has now been successfully installed on your Linux system.