尝试安装第三方组件 Oracle Java 8 时遇到问题。每次我输入:
$ sudo apt-get install oracle-java8-installer
我得到了这样的答案:
Reading package lists... Done
Building dependency tree
Reading state information... Done
oracle-java8-installer is already the newest version (8u131-1~webupd8~2).
The following package was automatically installed and is no longer required:
snap-confine
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 10 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]
Setting up oracle-java8-installer (8u131-1~webupd8~2) ...
Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc
Downloading Oracle Java 8...
--2017-07-05 15:57:12-- http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 2.22.144.107, 2.22.144.51
Connecting to download.oracle.com (download.oracle.com)|2.22.144.107|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-07-05 15:57:12 ERROR 403: Forbidden.
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
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
我想我无法安装 Oracle JDK 8。我尽力尝试了,但出现了这个错误。
答案1
这是因为 PPA 维护者尚未更新其脚本,并且 Oracle 不再提供 Java 8 的旧更新。
为了快速解决此问题,您可以执行以下操作并安装 8u151。(这仅在 Oracle 提供 8u151 时才有效)
1)正常安装:
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo
debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
完成后您会收到错误:
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer E: 子进程 /usr/bin/dpkg 返回错误代码 (1)
2) 然后您必须执行以下操作才能安装 8u151:
cd /var/lib/dpkg/info
sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|' oracle-java8-installer.*
sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u151|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_151|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/$FILENAME|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/$FILENAME|' oracle-java8-installer.*
3)完成以上操作后,您可以再次运行安装,并且安装将会成功。
sudo apt install -y oracle-java8-installer
答案2
你收到此403:Forbidden
错误:
正在解析 download.oracle.com (download.oracle.com)... 2.22.144.107, 2.22.144.51 连接到 download.oracle.com (download.oracle.com)|2.22.144.107|:80... 已连接。 HTTP 请求已发送,正在等待响应...403 禁止 2017-07-05 15:57:12 错误 403:禁止。
因为 Oracle Java 8 安装程序要求您在安装开始之前接受 Oracle 许可证。您可以运行以下命令来自动接受 Oracle 许可证:
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
或者,您可以从以下位置手动下载 JDK tar.gz 档案Java SE 下载并将其放置在下面/var/cache/oracle-jdk8-installer
然后安装oracle-java8-安装程序包将使用本地档案而不是尝试自行下载。