本文介绍了未安装JDK 8 - 错误404:未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从昨天开始,我一直在尝试在我的Ubuntu机器上安装JDK8,但它一直在失败。



我一直试图运行命令:

  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

但我无法继续,因为在运行命令 sudo apt-get install oracle-java8-installer 时,我得到的是:

  ... 
连接到download.oracle.com(download.oracle.com)| 23.215.130.99 |:80 .. 。 连接的。
HTTP请求已发送,等待响应... 404未找到
2017-10-18 11:07:34错误404:未找到。

下载失败
未安装Oracle JDK 8。
dpkg:错误处理包oracle-java8-installer( - configure):
安装后的子进程安装后脚本返回错误退出状态1
...

我的设置是64位Ubuntu 14.04。

解决方案

经过大量的谷歌搜索后,我在



复制带您进入所需下载的链接。不要忘记接受许可协议。在我的情况下(Linux的x64)的,我需要: http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar .gz



出于本教程的目的,我们只需要链接的路径: http:// download .oracle.com / OTN-酒馆/ JAVA / JDK / 8u181-B13 / 96a7b8442fe848ef90c96a2fad6ed6d1 / 。保持安全;我们稍后会需要它。



现在查看页面中的校验和链接和



这会带您进入计划html表页面。只需查找适合您机器的 sh256





再次我的机器是 的Linux 64,所以我需要 1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3 ,像在图像。复制该值,并保持安全;我们以后也需要它。



现在,打开计算机上的终端并输入java安装程序文件所在的文件夹:

  cd / var / lib / dpkg / info 

很棒,现在输入这个:

  sudo grep --color -PJAVA_VERSION = [a-z0-9] +oracle-java8-installer .config 

输出应如下所示:





这告诉我们安装程序配置安装的java版本是什么。所以

  sudo sed -i's | JAVA_VERSION =< INSTALLER CURRENT JAVA VERSION HERE> | JAVA_VERSION =< NEW VERSION HERE> ; |'oracle-java8-installer。* 

对于我们的情况,我们从<$ c升级$ c> 8u171 到 8u181 ,所以我们会执行

  sudo sed -i's | JAVA_VERSION = 8u171 | JAVA_VERSION = 8u181 |'oracle-java8-installer。* 

好的,现在我们需要更新下载网址。

  sudo grep --color -P PARTNER_URL = [^] +oracle-java8-installer.config 


要更新它,我们应该执行如下命令:

  sudo sed -i's | PARTNER_URL =< INSTALLER CURRENT JAVA URL HERE> | PARTNER_URL =< NEW URL HERE> |'oracle-java8-installer。* 

请记住我告诉你在开始时保存的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-安装程序。* 

之后,我们需要更新校验和。所以请执行以下命令:

  sudo grep --color -P'[^#] SHA256SUM_TGZ =[^] + 'oracle-java8-installer.config 

这打印出几个不同的SHA256:





请注意,它们都是不同的。我们会在因此,要更新SHA256,我们需要执行以下命令:

  sudo sed -i's | SHA256SUM_TGZ =< INSTALLER CURRENT JAVA HASH HERE>| SHA256SUM_TGZ =< NEW JAVA HASH>|'oracle-java8-installer。* 

但我们怎么知道当前哪些Java哈希要替换呢?好吧,我们需要找出我们处理器的架构:

  dpkg --print-architecture 

在我的情况下,这将是输出 amd64 。这个意味着我应该抓住第二个链接。我怎么知道这个?好吧,我读了源代码( sudo gedit oracle-java8-installer.config ),所以请相信我:




  • 如果您的架构是 i386 i586 i686 ,抓住第一个。

  • 如果 amd64 ,抓住第二个。

  • 如果 armv7l armv6l ,请抓住第三个。

  • 如果 armv8l arm64 aarch64 ,抓住第四个。

  • 如果以上都不是,那你就不走运了......



所以,因为我的 amd64 ,使用我们从Java网站获得的新哈希,我会执行:

 须藤SED -i的| SHA256SUM_TGZ = b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982 | SHA256SUM_TGZ = 1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3 |。甲骨文java8-安装* 

最后,我们需要修改安装程序JDK目录name,所以执行此命令以查找当前的名称:

  sudo grep --color -PJ_DIR = [^] + oracle-java8-installer.config 

在我的情况下打印出来:





因此我们将执行以下操作:

  sudo sed -i | J_DIR =< INSTALLER CURRENT JDK VERSION HERE> | J_DIR =< NEW JDK VERSION> |'oracle-java8-installer。* 

成为我当前的版本 jdk1.8.0_171 ,我执行:

  sudo sed -i's | J_DIR = jdk1.8.0_171 | J_DIR = jdk1.8.0_181 |' oracle-java8-installer。* 

而且......就是这样。我们已经准备好调用java安装程序了。 (phew ...这需要更长的时间来打字我最初想的。)






Edit4 @Glenn Smith旧版本的命令使用从 8u171 8u181 (如果它对任何人都很方便,不过它应该已经使用新的构建文件删除了)

  cd / var / lib / dpkg / info 
sudo sed - 我是| JAVA_VERSION = 8u171 | JAVA_VERSION = 8u181 |'oracle-java8-installer。*
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/ |甲骨文java8的安装程序*
须藤的sed - 我的| SHA256SUM_TGZ = b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982 | SHA256SUM_TGZ = 1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3 |。甲骨文java8的安装程序*
须藤sed的-i的| J_DIR = jdk1.8.0_171 | J_DIR = jdk1.8.0_181 | oracle-java8-installer。*






Edit3 @Kenny Hung旧版命令从 8u161 8u171 使用(如果它对任何人都很方便,尽管它应该已经被新版本删除了文件)

  cd / var / lib / dpkg / info 
sudo sed -i's | JAVA_VERSION = 8u161 | JAVA_VERSION = 8u171 | '甲骨文java8的安装程序*
须藤的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。*






EDIT2 @马丁Šuráb/ @阿尔伯特钟/ 的旧版命令从 8u151 8u162 (如果它来了)方便任何人,虽然它应该已经删除了新的构建文件)

  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。*
须藤sed的-i的| SHA256SUM_TGZ = c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f | SHA256SUM_TGZ = 68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257 |甲骨文java8的安装程序*
须藤sed的-i的|。J_DIR = jdk1.8.0_151 | J_DIR = jdk1.8.0_162 |'oracle-java8-installer。*






Edit1 G1zmo2的旧版本命令使用从 8u144 8u152 (在它对任何人来说都很方便,虽然它应该已经被新的构建文件删除了):

  cd / var / lib / dpkg / info 
sudo sed -i's | JAVA_VERSION = 8u144 | JAVA_VERSION = 8u152 |'oracle-java8-installer。*
sudo 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- 。安装*
须藤sed的-i的| SHA256SUM_TGZ = e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4 | SHA256SUM_TGZ = 218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf |。甲骨文java8的安装程序*
须藤sed的-i的| J_DIR = jdk1.8.0 _144 | J_DIR = jdk1.8.0_152 |'oracle-java8-installer。*


Since yesterday, I've been trying to install the JDK8 on my Ubuntu machine, but it has been failing constantly.

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:

...
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.

解决方案

After a lot of googling around I found a answer on the Ubuntu forum.

Basically, the problem seems to be that there is a new version of java and the installer wasn't updated to reference it.

If your machine is a Linux x64 with an AMD64 processor, and you need the latest Java8 version, this can be easily fixed by running these commands (Credit for the original version goes to g1zmo2 and this updated version goes to @MinneapolisCoder9):

cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u181|JAVA_VERSION=8u191|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3"|SHA256SUM_TGZ="53c29507e2405a7ffdbba627e6d64856089b094867479edc5ede4105c1da0d65"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_181|J_DIR=jdk1.8.0_191|' oracle-java8-installer.*

And then running the JDK 8 installer commands like you normally would =):

sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default


If your machine is not a Linux x64 AMD64 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.

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).

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).

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".

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.

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.

Now look up the checksum link in the page and click it.

This should take you to a plan html table page. Just look for the sh256 that fits your machine.

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.

Now, open a terminal on your machine and enter the folder where the java installer file are:

cd /var/lib/dpkg/info

Great, now type 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

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"

sudo sed -i 's|JAVA_VERSION=8u171|JAVA_VERSION=8u181|' oracle-java8-installer.*

Ok, now we need to update the download 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 is as your new url, like this:

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:

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:

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:

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:

  • If your architecture is i386, i586 or i686, grab the first one.
  • If amd64, grab the second one.
  • If armv7l or armv6l, grab the third one.
  • If armv8l, arm64 or aarch64, grab the fourth one.
  • If none of the above, you are out of luck...

So, as mine is amd64, using the new hash we obtained from Java's website, I would execute:

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:

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:

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).


Edit4 @Glenn Smith older version of commands used from 8u171 to 8u181 (in case it comes handy to anyone, though it should have been removed with the new build files)

cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u171|JAVA_VERSION=8u181|' oracle-java8-installer.*
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.*
sudo sed -i 's|SHA256SUM_TGZ="b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982"|SHA256SUM_TGZ="1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_171|J_DIR=jdk1.8.0_181|' oracle-java8-installer.*


Edit3 @Kenny Hung older version of commands used from 8u161 to 8u171 (in case it comes handy to anyone, though it should have been removed with the new build files)

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.*


Edit2 @Martin Šuráb/@Albert Zhong/p-ansell's older version of commands used from 8u151 to 8u162 (in case it comes handy to anyone, though it should have been removed with the new build files)

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.*


Edit1 G1zmo2's older version of commands used from 8u144 to 8u152 (in case it comes handy to anyone, though it should have been removed with the new build files):

cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
sudo 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.*
sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*

这篇关于未安装JDK 8 - 错误404:未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 10:32