我卸载了 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)
答案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.*
答案2
首选好友解决方案
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
答案3
我刚刚遇到了同样的问题并做了以下操作:
cd /var/lib/dpkg/info/
- 在所有文件中将
oracle-java9-installer.*
版本号 177->178 和 SHA256SUM_TGZ 更改为您在官方网站上看到的内容 sudo apt-get install oracle-java9-installer
我知道这是肮脏和不正确的方法,但我没有找到任何其他方法
答案4
安装程序的最新版本 9.0.1-1~webupd8~0 现在可以正常运行。
先前的答案不适用于安装程序的 9b181-1~webupd8~2 版本以及一些先前的版本。
注意,JDK 版本现在是 9.0.1,而不是安装程序预期的 9 (beta)。它已经过时,下载也已被(重新)移除,因此甚至无法安装旧 beta。
以下有效:
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
/var/cache/oracle-jdk9-installer
您也可以单独下载 java9 tgz 包,并在尝试安装(失败)后将其放入(它将创建目录)。执行上述修复后,它将从缓存版本安装(保留备份副本),而不是尝试再次下载。