Java installation on Ubuntu 20.04

Oracle JRE under Ubuntu focal using linuxuprising/java
ubuntu
java
Published

January 14, 2021

Following these instructions: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-20-04-fr.

Current configuration

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

Download Oracle JDK 11

From https://launchpad.net/~linuxuprising/+archive/ubuntu/java/+packages, I can identify the focal version:

oracle-java11-installer-local - 11.0.9-1~linuxuprising0 (changes file) logix2 2020-10-22 Published Focal Java

I download the given version from Oracle website: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html. Java SE Development Kit 11.0.9 Linux x64 Compressed Archive

And yes you have to login with an oracle account to download it.

Installation via linuxuprising/java

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo mkdir -p /var/cache/oracle-jdk11-installer-local/
sudo cp ~/Downloads/jdk-11.0.9_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
sudo apt install oracle-java11-installer-local

After accepting the license agreement, installation is running

Check

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
* 2            /usr/lib/jvm/java-11-oracle/bin/java          1091      manual mode

Environment variable

Enter /usr/lib/jvm/java-11-oracle as your JAVA_HOME variable in /etc/environment

$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
JAVA_HOME="/usr/lib/jvm/java-11-oracle"
$ source /etc/environment
$ echo $JAVA_HOME
/usr/lib/jvm/java-11-oracle