How can I install the latest jdk 9 using terminal command on ubuntu 16.04 LTS ?

Install

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

Update your environment variable after that

sudo nano /etc/environment

Add / Edit this line

JAVA_HOME="/usr/lib/jvm/java-9-oracle"

Save and run

source /etc/environment

Test if environment variable was set

echo $JAVA_HOME

(Optional) For Linux Mint Users:

sudo apt install gsfonts-x11 oracle-java9-set-default

Update: Oracle Java 9 has reached end of life. Users of Java SE 9 should switch to Java SE 10. Source

To install Java 10, follow this.

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java10-installer

Source

Tags:

Java

Ide

Jdk

16.04