Ubuntu – Cannot install Oracle JDK via apt in Ubuntu 16.04

aptjavajdkoraclesoftware installation

I created a new Ubuntu 16.04.3 VM and am attempting to install JDK 9. Unfortunately, the latest version of the JDK apt installer, 9.0.1-1~webupd8~0, is failing to download the binaries and I suspect that the reason is because JDK 9.0.4 was released today and Oracle moved the archives around.

I carried out the typical steps for installation:

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

I am then prompted with the following error message:

Downloading Oracle Java 9...
--2018-01-16 15:15:07--  http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz
Resolving download.oracle.com (download.oracle.com)...
Connecting to download.oracle.com (download.oracle.com)||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz [following]
--2018-01-16 15:15:11--  https://edelivery.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)..., 2600:1404:21:49d::2d3e, 2600:1404:21:493::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz?AuthParam=1516137431_0e89d10b30203a572ea858768475ef74 [following]
--2018-01-16 15:15:11--  http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz?AuthParam=1516137431_0e89d10b30203a572ea858768475ef74
Connecting to download.oracle.com (download.oracle.com)||:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-01-16 15:15:11 ERROR 404: Not Found.

download failed
Oracle JDK 9 is NOT installed.
dpkg: error processing package oracle-java9-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I found this thread that addressed it for the JDK 9 GA, but it does not appear that the latest reply works for JDK 9.0.4+11. I've updated the SHA checksums (found on this page), set the major version to 9.0.4, and set the minor version to 11, but I'm still not having success.

What steps need to be carried out to get the JDK apt installer to work until the WebUpd8 team is able to update the PPA?

Best Answer

  • 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

  • Related Question