Cannot install Oracle JDK via apt in Ubuntu 16.04

Solution 1:

First of all in case you think you need Oracle Java because of some stupid tutorial you found on the internet, all you need to do to install Java in all currently supported versions of Ubuntu is to run this command:

sudo apt install default-jdk   

If you're continuing on to read the rest of this answer, then you think that you need to install Oracle Java instead of the installing a Java package from the default Ubuntu repositories.


I tried to download Oracle Java 9 manually from the official Oracle website at: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html and the link to download jdk-9.0.4_linux-x64_bin.tar.gz is working. If download link is not working because it's been updated, go to the official Oracle website and download Java from there. Your other alternative is to install openjdk-9-jdk from the default Ubuntu 16.04 repositories.

Install Oracle Java JDK the manual way


Java 8 can also be installed the same way. The link to download Java 8 manually from the official Oracle website is: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Solution 2:

For people just arriving at this question, Oracle Java 9, because it is not an LTS version, is now end-of-life and cannot be downloaded. Unfortunately, Java 10 isn't yet available through the Web Upd8 PPA, but their PPA page recommends another PPA for that.

Oracle Java 8

Java 8 is an LTS version that will last a lot longer than Java 10 and can be installed with:

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

Oracle Java 10

Java 10 is a non-LTS version that won't last long and can be installed with:

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