How to Install Oracle Java 12 in Ubuntu 18.04 / 16.04

java-icon-4012031

Oracle Java 12 was released a few days ago. Now you can easily install it via PPA in Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, Ubuntu 18.10, and higher.

An installer script was create to make installing Oracle Java 12 easy in Ubuntu. It automatically downloads java package from Oracle web server, and installs it on your system. The “Linux Uprising” team PPA maintains the installer script for all current Ubuntu releases.

1. To add the PPA, open terminal either from app launcher or by pressing Ctrl+Alt+T on keyboard. When it opens, run command:

sudo add-apt-repository ppa:linuxuprising/java

Type user password (no asterisk feedback due to security reason) for sudo prompt and hit Enter.

2. Then run commands to install the script to start downloading and installing Java 12 on your Ubuntu:

sudo apt-get update

sudo apt-get install oracle-java12-installer

For Ubuntu 18.04 and higher, skip sudo apt-get update command since it’s done automatically after adding PPA.

3. If you have installed multiple Java versions, install (or remove) oracle-java12-set-default package to set (or not set) Java 12 as default.

sudo apt-get install oracle-java12-set-default

Finally check Java version via java -version:

Uninstall:

To remove Oracle Java 12, run command to remove the installer script:

sudo apt-get remove oracle-java12-installer

And go to Software & Updates -> Other Software to remove the PPA repository.

Original Article