我使用以下命令在我的 ubuntu 服务器上安装 java 8:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo update-java-alternatives -s java-8-oracle
但是在一台服务器上,当我输入 apt-get install oracle-java8-installer....并接受条款后,出现了问题...
问题如下:
Downloading Oracle Java 8...
--2017-06-02 21:25:56-- download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 2.16.4.176, 2.16.4.178
Connecting to download.oracle.com (download.oracle.com)|2.16.4.176|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: edelivery.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz [following]
--2017-06-02 21:25:56-- edelivery.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 2.21.253.143, 2a02:26f0:2d:481::2d3e, 2a02:26f0:2d:483::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|2.21.253.143|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: (download(.)oracle(.)com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz?AuthParam=1496431676_6bda1c9f8e9f814775eb5960113152cc [following]
--2017-06-02 21:25:56-- download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz?AuthParam=1496431676_6bda1c9f8e9f814775eb5960113152cc
Connecting to download.oracle.com (download(.)oracle(.)com)|2.16.4.176|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-06-02 21:25:58 ERROR 404: Not Found.
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
dpkg: dependency problems prevent configuration of oracle-java8-set-default:
oracle-java8-set-default depends on oracle-java8-installer; however:
Package oracle-java8-installer is not configured yet.
dpkg: error processing package oracle-java8-set-default (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
oracle-java8-installer
oracle-java8-set-default
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
以下命令详细说明如下 在 Ubuntu 16.04、Linux Mint 18 中安装 Oracle Java 8/9
简单来说,步骤如下:
添加 PPA。打开终端(Ctrl+Alt+T)并运行命令:
sudo add-apt-repository ppa:webupd8team/java
更新并安装安装程序脚本
sudo apt update; sudo apt install oracle-java8-installer
检查 Java 版本:安装包后,要检查 Java 版本,请运行命令:
javac -version
设置 Java 环境变量
sudo apt install oracle-java8-set-default