无法在 Xubuntu 18.04 中安装 Java 8

无法在 Xubuntu 18.04 中安装 Java 8

我无法在 Xubuntu 18.04/ 中安装 Java 8

sudo apt-get install oracle-java8-installer
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
oracle-java8-installer is already the newest version (8u201-1~webupd8~1).
0 upgraded, 0 newly installed, 0 to remove and 197 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-java8-installer (8u201-1~webupd8~1) ...
Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc
Downloading Oracle Java 8...
--2019-04-17 21:34:46--  http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.32.64.102
Connecting to download.oracle.com (download.oracle.com)|23.32.64.102|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz [following]
--2019-04-17 21:34:46--  https://edelivery.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 88.221.34.197, 2600:1403:2:59e::366, 2600:1403:2:580::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|88.221.34.197|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz?AuthParam=1555551407_c7bf9550ae418012627e2e12b0261dc8 [following]
--2019-04-17 21:34:47--  http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz?AuthParam=1555551407_c7bf9550ae418012627e2e12b0261dc8
Connecting to download.oracle.com (download.oracle.com)|23.32.64.102|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz?AuthParam=1555551407_c7bf9550ae418012627e2e12b0261dc8 [following]
--2019-04-17 21:34:47--  https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz?AuthParam=1555551407_c7bf9550ae418012627e2e12b0261dc8
Connecting to download.oracle.com (download.oracle.com)|23.32.64.102|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-04-17 21:34:50 ERROR 404: Not Found.

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 installed oracle-java8-installer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

Ubuntu 14 中也存在同样的问题。

这是因为 Oracle 已从 201 版本升级到 211 版本,从其资源中删除了 201。而且 webupd8team 尚未更正链接。

检查这个解决方案:

mkdir -p /opt/jdk
wget https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz?AuthParam=1555549457_a97b02ea0e2d39aeaf0e2a1d180a6b7e

手动下载这里,我们需要jdk-8u211-linux-x64.tar.gzjdk-8uXXX-linux-x64.tar.gz

tar -zxf jdk-8u211-linux-x64.tar.gz -C /opt/jdk/

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_211/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_211/bin/javac 100

update-alternatives --display java
update-alternatives --display javac

java -version

每次运行 apt-get update 时取消安装:

apt-get remove oracle-java8-installer
apt-get purge oracle-java8-installer
apt-mark hold oracle-java8-installer

相关内容