问题
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.
回答1:
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:
- http://ftp.osuosl.org/pub/funtoo/distfiles/oracle-java/
- http://ftp.heanet.ie/mirrors/funtoo/distfiles/oracle-java/
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:
- https://www.oracle.com/webfolder/s/digest/7u80checksum.html
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
回答2:
So looks like the direct links to the download no longer work( As noted by Meir Maor above)
Here are the steps to get this running again:
Go to http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html and accept the license. Download the file we need (jdk-7u80-linux-x64.tar.gz in this case)
Assuming the file downloaded to your Downloads directory, we need to move it to /var/cache/oracle-jdk7-installer
cd ~/Downloads (Change to directory to which you saved file from step 1) sudo mkdir /var/cache/oracle-jdk7-installer sudo mv jdk-7u80-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/
Not sure if necessary but I had luck with this:
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
Run the installer now. It will use the file we saved in /var/cache instead of trying to download it from Oracle
sudo apt-get install oracle-java7-installer
I got step 3 from http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
回答3:
I just ran into this trying to install Java 6 (don't ask).
Since I'm short on time, I was fine with a quick and dirty answer. I noticed the URL looked for by the installer was http-based (vs https), which makes the below solution possible.
Make sure a web server is installed (I already had Apache on my box)
Download the file that is requested. In your case that is
jdk-7u80-linux-x64.tar.gz
. See Meir Maor's answer aboveOn your local web server, recreate the path structure requested for the file. In your case that is
otn-pub/java/jdk/7u80-b15
.Copy the downloaded file into the path above
Edit /etc/hosts and add
127.0.0.1 download.oracle.com
Run
apt-get install -y oracle-java7-installer
again.The installer will now grab the file from your local web server and complete successfully.
There may be a better way to do this, but it worked for me.
回答4:
As Oracle support for debian packages has gone quite a while ago, I suppose that you use the method of webupd8
Go to their instructions I linked before and check if your configuration is still valid.
They also provide a method to install Java 8: Install Oracle Java 8 in Ubuntu (Debian instructions linked from there.)
Edit: I think that Oracle does not provide a public download of Java 7 anylonger - you would have to download it from the Java Archive. (http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html)
You could try to download the rpm package and use alien
to convert it to a .deb package. And did you already consider updating to Java 8?
回答5:
You can find the webupd8team ppa's online. The oracle-java7-installer has the version number "7u80+7u60arm-0~webupd8~1" I'm guessing this defect would occur for all the provided ubuntu versions!
Looking in one of the ppa's a few of the files directly reference the broken url identified by Meir Maor
debian/oracle-java7-unlimited-jce-policy.postinst:PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/7/$FILENAME
debian/oracle-java7-unlimited-jce-policy.config:PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/7/$FILENAME
debian/oracle-java7-installer.config: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u80-b15/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.config: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u60-b19/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.postinst: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u80-b15/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.postinst: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u60-b19/$FILENAME # Must be modified for each release!!!
unfortunately I can't figure out how to lodge a defect with them (yet) but presumably this would be a quick fix
来源:https://stackoverflow.com/questions/44142450/apt-get-installing-oracle-java-7-stopped-working