Let’s see how you Install Oracle Java 12 on Ubuntu 19.04/18.04/16.04. Java 12 reached General Availability on 19 March 2019 with Production-ready binaries released. It is not an LTS release like Java 11. For production use, I recommend you install Java 11 LTS.

For CentOS / RHEL / Fedora, check How to Install Java 12 (OpenJDK 12) on CentOS / Fedora

Oracle JDK 12 packages for Ubuntu are available on Linuxuprising PPA repository. Add it to your Ubuntu system.

sudo apt update
sudo add-apt-repository ppa:linuxuprising/java

Java JDK 12 can then be installed on Ubuntu 19.04/18.04/16.04 using the command:

sudo apt install oracle-java12-installer

To set Oracle JDK12 as default, install the “oracle-java12-set-default” package.

sudo apt y install oracle-java12-set-default

Confirm your Java version.

$ java -version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

Set Java environment.

sudo vim /etc/profile.d/jdk.sh

Add:

export JAVA_HOME=/usr/lib/jvm/java-12-oracle
export PATH=$PATH:$JAVA_HOME/bin

Update your environment:

source /etc/profile.d/jdk.sh

You can also download Java SE Development Kit 12 Debian packages from oracle website.

curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15208a647278a19ef0990eea691/jdk-12.0.1_linux-x64_bin.deb"

Then install the package with the dpkg command:

sudo dpkg -i jdk-12.0.1_linux-x64_bin.deb

Awesome!. Java 12 has been installed on your Ubuntu 19.04/18.04/16.04. Similar guides:

Set JAVA_HOME on CentOS / RHEL / Fedora

How to Install Apache Hadoop / HBase on Ubuntu 18.04

How to Install Java 8 on Ubuntu 18.04/16.04