Thursday, September 4, 2025
HomeGuest BlogsInstall Java 11 on Ubuntu 22.04|20.04|18.04

Install Java 11 on Ubuntu 22.04|20.04|18.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

In this tutorial, I’ll walk you through the steps to install Oracle Java 11 on Ubuntu 22.04|20.04|18.04. Java 11 is a long-term support (LTS) release made available to the General public on 25 September 2018 and is production-ready. Java is one the the widely adopted and loved programming language for building backend applications. It has a huge community which has been so impactful in actualizing its success.

You can install Java 11 on Ubuntu 22.04|20.04|18.04 either from one of the following methods:

  1. Java SE Development Kit 11 (JDK 11)
  2. OpenJDK 11

This guide will cover the installation of Oracle Java 11 on Ubuntu 22.04|20.04|18.04 from both methods.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Method 1: Install Java 11 from Upstream repo / PPA – Recommended

For Ubuntu 22.04/20.04 , run:

sudo apt update
sudo apt install openjdk-11-jdk

Ubuntu 18.04

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java11-set-default

If you don’t want to set Java 11 as default, then install:

sudo apt install oracle-java11-installer

Conform Java verison:

$ java -version
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)

Setting Default version of Java

If you have more than one version of Java installed in your system, you can refer to our guide on how to set default version for all applications.

How to set default Java version on Ubuntu / Debian

Method 2: Manually install OpenJDK 11 on Ubuntu 22.04|20.04|18.04

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2.

Check the latest release of OpenJDK 11 before running the command below:

wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

This will download OpenJDK 11 tar file to your working directory. After the download, extract the archive

tar zxvf openjdk-11+28_linux-x64_bin.tar.gz

Move the resulting folder to /usr/local/

sudo mv jdk-11* /usr/local/

Set environment variables

sudo vim /etc/profile.d/jdk.sh

Add:

export JAVA_HOME=/usr/local/jdk-11
export PATH=$PATH:$JAVA_HOME/bin

Source your profile file and check java command

$ source /etc/profile 
$ java -version
openjdk version "11.0.2" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

$ which java
/usr/local/jdk-11.0.2/bin/java

Method 3: Manually Install Java SE Development Kit 11 (JDK 11)

Download the latest release of JDK 11.

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.12%2B8/f411702ca7704a54a79ead0c2e0942a3/jdk-11.0.12_linux-x64_bin.deb

Then install the package with the dpkgcommand

sudo apt install ./jdk-11.0.12_linux-x64_bin.deb

If you encounter dependency issues, then run:

sudo apt -f install
sudo dpkg -i jdk-11.0.12_linux-x64_bin.deb

Set environment variable for Java.

sudo vim /etc/profile.d/jdk.sh

Add:

export JAVA_HOME=/usr/lib/jvm/jdk-11.0.12/
export PATH=$PATH:$JAVA_HOME/bin

Source the file and confirm Java version installed

$ source /etc/profile.d/jdk.sh
$ java -version
java version "11.0.12" 2021-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode

Recommended books:

For CentOS 7 & Fedora Linux distributions, refer to:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS