ubuntu安装jdk8
2018-12-03 本文已影响0人
时彬斌
ubuntu16.04上安装openjdk8一直失败,没有成功,报错信息如下:
# sudo add-apt-repository ppa:openjdk-r/ppa
# sudo apt-get update
# sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openjdk-8-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
openjdk-9-source
E: Package 'openjdk-8-jdk' has no installation candidate
按照提示安装openjdk-9-source,依然报错:
# sudo apt-get install openjdk-9-source
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
openjdk-9-source : Depends: openjdk-9-jre (>= 9.0.4+12-4ubuntu2~16.04.4) but it is not going to be installed
Depends: openjdk-9-jdk (>= 9.0.4+12-4ubuntu2~16.04.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
折腾了好久,网上说的方法主要是说sources.list有问题,更新后也没成功,看了openjdk的官网,16.04默认安装jdk版本是7,但是尝试安装依然失败........
无奈换了安装orcale的jdk8,能成功安装,步骤如下:
# sudo add-apt-repository ppa:webupd8team/java
# sudo apt-get update
# sudo apt-get install oracle-java8-installer
# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
--------2019-05-08 更新-------
今天在一台ubuntu16.04的机器上成功安装openjdk8
步骤如下:
以下均在root用户下操作
sudo apt-get update
sudo apt-get install openjdk-8-jdk
中间会让输入一个Y,如下图所示
![](https://img.haomeiwen.com/i8689365/73984eaa2cb70d74.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
当出现done done 的字样时代表安装成功了
java -version 看看吧