我正在尝试在 Ubuntu 18.04 上安装oracle-java8-installer
,使用以下命令:
apt-get update
apt-get install --yes --no-install-recommends software-properties-common && add-apt-repository ppa:webupd8team/java -y && echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
apt-get install oracle-java8-installer
突然,这开始失败了:
Downloading Oracle Java 8...
--2019-01-15 21:37:57-- http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.198.4.45
Connecting to download.oracle.com (download.oracle.com)|23.198.4.45|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz [following]
--2019-01-15 21:37:57-- https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.34.18.118, 2001:4de0:2204:98::366, 2001:4de0:2204:93::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.34.18.118|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547588398_34b19094b1b04e5117af5cb53859faab [following]
--2019-01-15 21:37:58-- http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547588398_34b19094b1b04e5117af5cb53859faab
Connecting to download.oracle.com (download.oracle.com)|23.198.4.45|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547588398_34b19094b1b04e5117af5cb53859faab [following]
--2019-01-15 21:37:58-- https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547588398_34b19094b1b04e5117af5cb53859faab
Connecting to download.oracle.com (download.oracle.com)|23.198.4.45|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-01-15 21:38:00 ERROR 404: Not Found.
该文件最近是否被删除或者移动了?
答案1
我们可以手动下载java并很容易地安装它。
下载java8版本:jdk-8u212-linux-x64.tar.gz
安装步骤:
sudo mkdir /usr/local/java
sudo tar xvzf jdk-8u212-linux-x64.tar.gz
sudo mv jdk1.8.0_212 /usr/local/java/
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_212/bin/javac" 1
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_212/bin/java" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_212/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/local/java/jdk1.8.0_212
sudo update-alternatives --config java
安装成功后检查版本。
sudo java -version