问题描述
我卸载了jdk包,现在无法安装回来。我成功安装了 oracle-java7-installer 和 oracle-java8-installer,但无法安装 oracle-java9-installer。看来我的计算机尝试下载错误版本的 oracle-java9-installer 177,而我能够下载的版本是 178。
$ wget http://download.java.net/java/jdk9/archive/178/binaries/jdk-9+178_linux-x64_bin.tar.gz
--2017-07-21 11:00:02-- http://download.java.net/java/jdk9/archive/178/binaries/jdk-9+178_linux-x64_bin.tar.gz
Connecting to 10.144.1.10:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 293348142 (280M) [application/x-gzip]
Saving to: 'jdk-9+178_linux-x64_bin.tar.gz'
jdk-9+178_linux-x64_bin.tar.gz 1%[> ] 5.42M 5.04MB/s ^C
$ wget http://download.java.net/java/jdk9/archive/177/binaries/jdk-9+177_linux-x64_bin.tar.gz
--2017-07-21 11:00:16-- http://download.java.net/java/jdk9/archive/177/binaries/jdk-9+177_linux-x64_bin.tar.gz
Connecting to 10.144.1.10:8080... connected.
Proxy request sent, awaiting response... 404 Not Found
2017-07-21 11:00:17 ERROR 404: Not Found.
你能帮我吗? apt-get
尝试安装 Oracle JDK 9。
我在win7托管的虚拟机中运行Ubuntu 16.04
完整错误消息:
sudo apt-get install oracle-java9-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
oracle-java9-installer is already the newest version (9b177-1~webupd8~0).
0 upgraded, 0 newly installed, 0 to remove and 147 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up oracle-java9-installer (9b177-1~webupd8~0) ...
Using wget settings from /var/cache/oracle-jdk9-installer/wgetrc
Downloading Oracle Java 9...
--2017-07-21 10:54:11-- http://download.java.net/java/jdk9/archive/177/binaries/jdk-9+177_linux-x64_bin.tar.gz
Connecting to 10.144.1.10:8080... connected.
Proxy request sent, awaiting response... 404 Not Found
2017-07-21 10:54:13 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:
oracle-java9-installerE: Sub-process /usr/bin/dpkg returned an error code (1)
最佳回答
对于 JDK 的 GA 发行版,请使用:
cd /var/lib/dpkg/info
sudo sed -i 's|SHA256SUM_TGZ="2ef49c97ddcd5e0de20226eea4cca7b0d7de63ddec80eff8291513f6474ca0dc"|SHA256SUM_TGZ="1c6d783a54fcc0673ed1f8c5e8650b1d8977ca3e856a03fba0090198e0f16f6d"|' oracle-java9-installer.*
sudo sed -i 's|JAVA_VERSION_MINOR=181|JAVA_VERSION_MINOR=181|' oracle-java9-installer.*
sudo sed -i 's|FILENAME=jdk-${JAVA_VERSION_MAJOR}+${JAVA_VERSION_MINOR}_linux-${dld}_bin.tar.gz|FILENAME=jdk-${JAVA_VERSION_MAJOR}_linux-${dld}_bin.tar.gz|' oracle-java9-installer.*
sudo sed -i 's|PARTNER_URL=http://download.java.net/java/jdk${JAVA_VERSION_MAJOR}/archive/${JAVA_VERSION_MINOR}/binaries/$FILENAME|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}+${JAVA_VERSION_MINOR}/$FILENAME|' oracle-java9-installer.*
次佳回答
更喜欢朋友解决方案
sudo apt-get install oracle-java9-installer
cd /var/lib/dpkg/info
sudo sed -i 's/=177/=179/' oracle-java9-installer.*
sudo sed -i 's/SHA256SUM_TGZ="a6905f3a4245a071880e1793b8d3d6100ef7b171ea1d6ebfe6312c25c2fca8bb"/SHA256SUM_TGZ="06fe58dfa50c4f6ca21dc1d475f16cd9e58db36b1d98582091d7ff9005dda7a7"/' oracle-java9-installer.*
sudo apt-get install oracle-java9-installer
第三种回答
我刚刚遇到了同样的问题并做了以下操作:
-
cd /var/lib/dpkg/info/
-
在所有文件
oracle-java9-installer.*
中将版本号177->178和SHA256SUM_TGZ更改为您在官方网站上看到的内容 -
sudo apt-get install oracle-java9-installer
我知道这是肮脏且不正确的方式,但我没有找到任何替代方法
第四种回答
最新版本的安装程序 9.0.1-1~webupd8~0 现在可以正常运行。
以前的答案不适用于安装程序的版本 9b181-1~webupd8~2 以及某些以前的版本。
请注意,JDK 版本现在是 9.0.1,而不是此安装程序预期的 9(测试版)。它已经过时了,下载也被(重新)移动了,所以它甚至无法安装旧的测试版。
以下工作有效:
sudo apt-get install oracle-java9-installer
您可以使用ls oracle-java9*
查看该目录中的相关文件:
cd /var/lib/dpkg/info
修复错误的总和,实际上是在 oracle-java9-installer.config
中:
sudo sed -i 's|SHA256SUM_TGZ="2ef49c97ddcd5e0de20226eea4cca7b0d7de63ddec80eff8291513f6474ca0dc"|SHA256SUM_TGZ="2cdaf0ff92d0829b510edd883a4ac8322c02f2fc1beae95d048b6716076bc014"|' oracle-java9-installer.*
修复 oracle-java9-installer.postinst
中的第二个错误总和:
sudo sed -i 's|SHA256SUM_TGZ="1c6d783a54fcc0673ed1f8c5e8650b1d8977ca3e856a03fba0090198e0f16f6d"|SHA256SUM_TGZ="2cdaf0ff92d0829b510edd883a4ac8322c02f2fc1beae95d048b6716076bc014"|' oracle-java9-installer.*
下一个:
sudo sed -i 's|JAVA_VERSION_MAJOR=9|JAVA_VERSION_MAJOR=9.0.1|' oracle-java9-installer.*
sudo sed -i 's|JAVA_VERSION_MINOR=181|JAVA_VERSION_MINOR=11|' oracle-java9-installer.*
sudo sed -i 's|J_DIR=jdk-9|J_DIR=jdk-9.0.1|' oracle-java9-installer.*
sudo sed -i 's|FILENAME=jdk-${JAVA_VERSION_MAJOR}+${JAVA_VERSION_MINOR}_linux-${dld}_bin.tar.gz|FILENAME=jdk-${JAVA_VERSION_MAJOR}_linux-${dld}_bin.tar.gz|' oracle-java9-installer.*
sudo sed -i 's|PARTNER_URL=http://download.java.net/java/jdk${JAVA_VERSION_MAJOR}/archive/${JAVA_VERSION_MINOR}/binaries/$FILENAME|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}+${JAVA_VERSION_MINOR}/$FILENAME|' oracle-java9-installer.*
然后再次安装:
sudo apt-get install oracle-java9-installer
您还可以单独下载 java9 tgz 包,并在尝试安装(但失败)后将其放置在 /var/cache/oracle-jdk9-installer
中(它将创建目录)。执行上述修复后,它将从缓存版本安装(保留备份副本),而不是尝试再次下载。