Java 未安装 JDK 8 - 错误 404:未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46815897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JDK 8 is NOT installed - ERROR 404: Not Found
提问by cavpollo
Since yesterday, I've been trying to install the JDK8 on my Ubuntu machine, but it has been failing constantly.
从昨天开始,我一直试图在我的 Ubuntu 机器上安装 JDK8,但它一直失败。
I've been trying to run the commands:
我一直在尝试运行以下命令:
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
But I can't continue because when running the command sudo apt-get install oracle-java8-installer
all I get is:
但我无法继续,因为在运行命令时sudo apt-get install oracle-java8-installer
我得到的是:
...
Connecting to download.oracle.com (download.oracle.com)|23.215.130.99|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-10-18 11:07:34 ERROR 404: Not Found.
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
...
My Setup is a 64-bit Ubuntu 14.04.
我的设置是 64 位 Ubuntu 14.04。
采纳答案by cavpollo
After a lot of googling around I found a answer on the Ubuntu forum.
经过大量的谷歌搜索后,我在 Ubuntu 论坛上找到了答案。
Basically, the problem seems to be that there is a new version of java and the installer wasn't updated to reference it.
基本上,问题似乎是有一个新版本的 java 并且安装程序没有更新以引用它。
If your machine is a Linux x64with an AMD64processor, you need the latest Java8 version, and you previously installed version 8u212
, this can be easily fixed by running these commands (Credit for the original version goes to g1zmo2):
如果您的机器是带有AMD64处理器的Linux x64,您需要最新的 Java8 版本,并且您之前安装了版本,这可以通过运行这些命令轻松修复(原始版本的信用转到g1zmo2):8u212
cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u212|JAVA_VERSION=8u221|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=https://download.oracle.com/otn/java/jdk/8u212-b10/59066701cf1a433da9770636fbc4c9aa/|PARTNER_URL=https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ=.*|SHA256SUM_TGZ="15ad4f7260d2416ac1558341d9d0a0ec5b83904e4ac4a22c8a3242e4e217649b"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_212|J_DIR=jdk1.8.0_2221|' oracle-java8-installer.*
And then running the JDK 8 installer commands like you normally would =):
然后像往常一样运行 JDK 8 安装程序命令 =):
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
If your machine is nota Linux x64 AMD64, your previous version wasn't 8u212
or you are looking for Java 9, well, you are in luck. Today is the day you'll learn to fix your java installer for your own needs.
如果你的机器是不是一个Linux的x64的AMD64,您以前的版本是不是8u212
和你正在寻找的Java 9,那么,你是幸运的。今天是您将学习根据自己的需要修复 Java 安装程序的日子。
For the purposes of this tutorial, we'll assume you want Java 8u181 and you had previously installed Java 8u171 (because that's what I have).
出于本教程的目的,我们假设您需要 Java 8u181 并且您之前已经安装了 Java 8u171(因为这就是我所拥有的)。
First, I need you to go to Java's JDK Downloads page (For Java8, go here, click the "Downloads" tab, and then the "Java SE 8u181" link).
首先,我需要您转到 Java 的 JDK 下载页面(对于 Java8,请转到此处,单击“下载”选项卡,然后单击“Java SE 8u181”链接)。
Now, look up the JDK version you need based on your machine. In my case, my machine is running on Ubuntu 14.04 64-bit, so I need "Linux x64".
现在,根据您的机器查找您需要的 JDK 版本。就我而言,我的机器在 Ubuntu 14.04 64 位上运行,所以我需要“Linux x64”。
Copy the link that takes you to the download you need. Don't forget to accept the license agreement. In my case (Linux x64), I need: http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz
.
复制带您到所需下载的链接。不要忘记接受许可协议。在我的情况下(Linux的x64)的,我需要:http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz
。
For the purposes of this tutorial, we only need the link's path: http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/
. Keep it safe; we'll need it later.
出于本教程的目的,我们只需要链接的路径:http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/
。保持安全;我们稍后会需要它。
Now look up the checksum link in the page and click it.
现在查找页面中的校验和链接并单击它。
This should take you to a plain html table page. Just look for the sha256
that fits your machine.
这应该带你到一个普通的 html 表格页面。只需寻找sha256
适合您机器的即可。
Again, my machine is a "Linux x64" so I need 1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3
, like in the picture. Copy the value, and keep it safe; we'll need it later too.
同样,我的机器是“Linux x64”,所以我需要1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3
,如图所示。复制值,并妥善保管;我们以后也需要它。
Now, open a terminal on your machine and enter the folder where the java installer file are:
现在,在您的机器上打开一个终端并输入 java 安装程序文件所在的文件夹:
cd /var/lib/dpkg/info
Great, now execute this:
太好了,现在执行这个:
sudo grep --color -P "JAVA_VERSION=[a-z0-9]+" oracle-java8-installer.config
The output should look something like this:
输出应如下所示:
This tells us what is the java version that the installer is configured to install. So to change those values easily we would run something like this:
这告诉我们安装程序配置为安装的 Java 版本是什么。因此,要轻松更改这些值,我们将运行如下代码:
sudo sed -i 's|JAVA_VERSION=<INSTALLER CURRENT JAVA VERSION HERE>|JAVA_VERSION=<NEW VERSION HERE>|' oracle-java8-installer.*
For our case, we are upgrading from 8u171
to 8u181
, so we would execute:
对于我们的案例,我们正在从 升级8u171
到8u181
,因此我们将执行:
sudo sed -i 's|JAVA_VERSION=8u171|JAVA_VERSION=8u181|' oracle-java8-installer.*
Ok, now we need to update the download url.
好的,现在我们需要更新下载 url。
sudo grep --color -P "PARTNER_URL=[^ ]+" oracle-java8-installer.config
To update it, we should execute a command like this:
要更新它,我们应该执行如下命令:
sudo sed -i 's|PARTNER_URL=<INSTALLER CURRENT JAVA URL HERE>|PARTNER_URL=<NEW URL HERE>|' oracle-java8-installer.*
Remember that URL I told you to save at the start? Well, we'll need it now. Place it as your new url, like this:
还记得我一开始告诉你要保存的 URL 吗?好吧,我们现在需要它。将其作为您的新网址,如下所示:
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/|' oracle-java8-installer.*
After that, we need to update the checksum. So please execute this command:
之后,我们需要更新校验和。所以请执行这个命令:
sudo grep --color -P '[^#]SHA256SUM_TGZ="[^"]+"' oracle-java8-installer.config
This prints out a couple different SHA256:
这会打印出几个不同的 SHA256:
Notice that they are all different. We'll get back at that in a second. So, to update the SHA256, we would need to execute this command:
请注意,它们都是不同的。我们稍后再谈。因此,要更新 SHA256,我们需要执行以下命令:
sudo sed -i 's|SHA256SUM_TGZ="<INSTALLER CURRENT JAVA HASH HERE>"|SHA256SUM_TGZ="<NEW JAVA HASH>"|' oracle-java8-installer.*
But how do we know which of the current Java hashes to replace? Well, we need to find out our processor's architecture:
但是我们如何知道要替换当前的哪个 Java 哈希值呢?好吧,我们需要找出我们处理器的架构:
dpkg --print-architecture
In my case, this will output amd64
. This means I should grab the second link. How do I know this? Well, I read the source code (sudo gedit oracle-java8-installer.config
), so trust me on this:
就我而言,这将输出amd64
. 这意味着我应该抓住第二个链接。我怎么知道这个?好吧,我阅读了源代码 ( sudo gedit oracle-java8-installer.config
),所以请相信我:
- If your architecture is
i386
,i586
ori686
, grab the first one. - If
amd64
, grab the second one. - If
armv7l
orarmv6l
, grab the third one. - If
armv8l
,arm64
oraarch64
, grab the fourth one. - If none of the above, you are out of luck...
- 如果您的架构是
i386
,i586
或i686
,请抓住第一个。 - 如果
amd64
,抓住第二个。 - 如果
armv7l
或armv6l
,抓住第三个。 - 如果
armv8l
,arm64
或aarch64
, 抓住第四个。 - 如果以上都不是,那你就不走运了......
So, as mine is amd64
, using the new hash we obtained from Java's website, I would execute:
因此,就像我一样amd64
,使用我们从 Java 网站获得的新哈希,我将执行:
sudo sed -i 's|SHA256SUM_TGZ="b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982"|SHA256SUM_TGZ="1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3"|' oracle-java8-installer.*
Finally, we need to modify the installers JDK directory name, so execute this to find the current one:
最后,我们需要修改安装程序 JDK 目录名称,因此执行以下命令以找到当前的:
sudo grep --color -P "J_DIR=[^ ]+" oracle-java8-installer.config
In my case this printed:
在我的情况下,这打印了:
So we would execute something like this:
所以我们会执行这样的事情:
sudo sed -i 's|J_DIR=<INSTALLER CURRENT JDK VERSION HERE>|J_DIR=<NEW JDK VERSION>|' oracle-java8-installer.*
Being my current version jdk1.8.0_171
, I execute:
作为我当前的版本jdk1.8.0_171
,我执行:
sudo sed -i 's|J_DIR=jdk1.8.0_171|J_DIR=jdk1.8.0_181|' oracle-java8-installer.*
And... that's it. We are ready to call the java installer, yay. (phew... this took longer to type that I thought at first).
而且……就是这样。我们已经准备好调用 java 安装程序了,是的。(呸……我一开始想的打字需要更长的时间)。
回答by Yu Franco
I believe the link provided by oracle is not correct try this one "http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz"
我相信oracle提供的链接不正确试试这个“ http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz”
回答by John-Henry Watkins
The following was my workaround for Ubuntu Mate 16.04 x64:
以下是我对 Ubuntu Mate 16.04 x64 的解决方法:
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz
mkdir /opt/jdk
sudo tar -zxf jdk-8u152-linux-x64.tar.gz -C /opt/jdk
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_152/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_152/bin/javac 100
Credit to digital oceanfor the header adjustment.
标题调整归功于数字海洋。
回答by OldMan
Above the .gz is missing from the URL for the download of java 8. wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz
用于下载 java 8 的 URL 中缺少 .gz 以上。 wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152 -b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz
回答by muya_
Adding to @cavpollo's answer, for those using Ansible, this task will get you there
添加到@cavpollo 的答案中,对于那些使用 Ansible 的人来说,这个任务会让你到达那里
- name: Patch Java installer
shell: "{{ item }}"
args:
chdir: "/var/lib/dpkg/info"
become: yes
with_items:
- sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
- sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/|' oracle-java8-installer.*
- sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
- sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*
回答by Albert Zhong
Thanks for cavpollo's answer for JDK 8u141.
感谢 cavpollo 对 JDK 8u141 的回答。
I'll give fix for JDK 8u151-1~webupd8~0(Use JDK 8i162 instead):
我将修复JDK 8u151-1~webupd8~0(改用 JDK 8i162):
cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' oracle-java8-installer.*
回答by Martin ?uráb
Since a few days ago this workaround is obsolete due to the new java release. Instead, use this replacement:
几天前,由于新的 Java 版本,此解决方法已过时。相反,使用此替换:
sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' oracle-java8-installer.*
sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' oracle-java8-installer.*
sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' oracle-java8-installer.*
sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' oracle-java8-installer.*
回答by Kenny Hung
And a newer version:
还有一个更新的版本:
cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u161|JAVA_VERSION=8u171|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="6dbc56a0e3310b69e91bb64db63a485bd7b6a8083f08e48047276380a0e2021e"|SHA256SUM_TGZ="b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_161|J_DIR=jdk1.8.0_171|' oracle-java8-installer.*
回答by al3gom3z
Let me share with you an update for JDK version 8u172
给大家分享一个JDK版本8u172的更新
sudo sed -i 's|JAVA_VERSION=8u161|JAVA_VERSION=8u172|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="6dbc56a0e3310b69e91bb64db63a485bd7b6a8083f08e48047276380a0e2021e"|SHA256SUM_TGZ="28a00b9400b6913563553e09e8024c286b506d8523334c93ddec6c9ec7e9d346"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_161|J_DIR=jdk1.8.0_172|' oracle-java8-installer.*
回答by Glenn Smith
Here it is for Java 8u181 as 8u171 is no longer working:
这是针对 Java 8u181 的,因为 8u171 不再工作:
cd /var/lib/dpkg/info
sed -i 's|JAVA_VERSION=8u171|JAVA_VERSION=8u181|' oracle-java8-installer.*
sed -i 's|J_DIR=jdk1.8.0_171|J_DIR=jdk1.8.0_181|' oracle-java8-installer.*
sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/|' oracle-java8-installer.*
sed -i 's|SHA256SUM_TGZ="b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982"|SHA256SUM_TGZ="1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3"|' oracle-java8-installer.*