In this article I will explain how to install Oracle Java on Ubuntu 16.04 LTS Server. I will explain the installation process of both Oracle Java 8 and 9.
1. Add the PPA
Run following command to add Webupd8team1 PPA repository.
$ sudo add-apt-repository ppa:webupd8team/java
2. Update Package Lists
Run following command to update apt package lists.
$ sudo apt update
3. Install Oracle Java 8 installer script
Run following command to run Oracle Java 8 installer script.
$ sudo apt install oracle-java8-installer
To install Java 9 replace oracle-java8-installer with oracle-java9-installer.
4. Verify Java installation
Run following command to verify Java 8 installation.
Verify Java runtime (JRE) version.
$ java -version
Verify Java compiler (JDK) version.
$ javac -version