apt-get installing oracle java 7 stopped working

ahong picture ahong · May 23, 2017 · Viewed 13k times · Source

Recently apt-get install -y oracle-java7-installer stopped working.

I know in their roadmap, I think the public version is no longer supported, but it's been working all the way until recently. http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Anyone have a work around for this?

http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1495560077_4041e14adcb5fd7e68827ab0e15dc3b1
Connecting to download.oracle.com (download.oracle.com)|96.6.45.99|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-05-23 10:19:17 ERROR 404: Not Found.

Answer

Meir Maor picture Meir Maor · May 24, 2017

It appears Oracle has moved the download link, you can still fetch the tar ball from the oracle website after jumping through some hoops. The WebUpd8 installer is currently broken. The official explanation can be found at http://www.webupd8.org/2017/06/why-oracle-java-7-and-6-installers-no.html


Download Method 1: Login into to Oracle site

The link now seems to be: http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz notice "otn" and not "otn-pub", but at least from the website you seem to need to be signed in and not only accept the license agreement.

It may be possible with debconf to change the url from otn-pub to otn and get the installer to work but I haven't tried. You can fetch the binary yourself and either install manually or with the installer pointing it to wherever you put the downloaded tar ball.

Edit: It seems there isn't a way to configure download URL (though you can hijack it with hosts as in another answer).

Download Method 2: Use a trusted mirror

If you want to download jdk-7u80-linux-x64.tar.gz from a script without logging into to oracle it hosted locations include:

EDIT: The sha256 has been removed from this answer because (as this edit demonstrates) anyone can edit said hash. Get your hashes from a trusted source. Suggestions include:


Install Method 1: Prepopulate cache

#put the file in the default cache location:
sudo mv jdk-7u80-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/

#then install normally: 
sudo apt-get install oracle-java7-installer

Install Method 2: (more elegant IMHO) put tar ball anywhere and tell the installer where to look

#setup ppa (you probably came here after already doing this)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

#put the file in a temporary location:
sudo mv jdk-7u80-linux-x64.tar.gz /tmp/


#set local path to /tmp (or any other path)
echo oracle-java7-installer oracle-java7-installer/local select /tmp | \
sudo /usr/bin/debconf-set-selections


#While your at it you may want tp approve license (or skip this and approve when prompted) 
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | \
sudo /usr/bin/debconf-set-selections

#then install normally: 
sudo apt-get install oracle-java7-installer