无法在 Ubuntu 18.10 中安装 Oracle Java 8

无法在 Ubuntu 18.10 中安装 Oracle Java 8

我尝试使用

# add-apt-repository -y ppa:webupd8team/java
# apt update
# apt install oracle-java8-installer

但出现错误:

ERROR 404: Not Found.

download failed
**Oracle JDK 8 is NOT installed.

我搜索了互联网并找到了解决方案:

cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u201|JAVA_VERSION=8u211|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/|PARTNER_URL=https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="cb700cc0ac3ddc728a567c350881ce7e25118eaf7ca97ca9705d4580c506e370"|SHA256SUM_TGZ="c0b7e45330c3f79750c89de6ee0d949ed4af946849592154874d22abc9c4668d"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_201|J_DIR=jdk1.8.0_211|' oracle-java8-installer.*

但现在我遇到了另一个错误:

Resolving login.oracle.com (login.oracle.com)... 156.151.58.18
Connecting to login.oracle.com (login.oracle.com)|156.151.58.18|:443... connected.
HTTP request sent, awaiting response... 401 Authorization Required

Username/Password Authentication Failed.
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)

这是什么 401 授权?我应该在任何地方输入凭证吗?请帮忙!

答案1

Azul 管理并免费提供 OpenJDK 7 到 12 的实用软件包。根据他们的指示,要安装一个或多个 Java 版本,您只需执行以下操作:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9
sudo apt-add-repository 'deb http://repos.azulsystems.com/ubuntu stable main'
sudo apt-install zulu-8

拥有功能齐全的 Java 8 环境。如果要安装多个 Java 版本,可以选择默认版本,就像通常在 Debian/ubuntu 中所做的那样:

update-java-alternatives -l                # to list available ones
update-java-alternatives -s zulu-8-amd64   # to set java8 as default

相关内容