Categories

  • articles

Tags

  • java

Java 11 is a LTS version, so should be the most popular version. I tested the steps below on Ubuntu version 14.04 and 16.04.

Installation

Here I will provide two option the Oracle and OpenJDK version. I would recommend the OpenJDK version just due to simple licensing agreement.

Add the following PPA and install as follow:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt update
sudo apt install openjdk-11-jdk

Oracle Java 11

Add the following PPA and install as follow:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java11-installer

Switch between Java versions

List all installed version of Java.

update-java-alternatives -l

Selecting new version of Java.

sudo update-java-alternatives -s java-1.11.0-openjdk-amd64

Also noted that in Ubuntu this does not update the JAVA_HOME and causes issues with few apps. To fix this just set the JAVA home in /etc/enviroment or if that file is not in your distro set in ~/.bashrc. If you are setting in the /etc/enviroment you need to restart to load.

JAVA_HOME="/usr/lib/jvm/java-1.11.0-openjdk-amd64"