使用ppa/源方式安装
1.添加ppa
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update
2.安装oracle-java-installer
jdk7
sudo apt-get install oracle-java7-installer
jdk8
sudo apt-get install oracle-java8-installer
安装器会提示你同意 oracle 的服务条款,选择 ok
然后选择yes 即可
如果你懒,不想自己手动点击.也可以加入下面的这条命令,默认同意条款:
JDK7 默认选择条款
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
JDK8 默认选择条款
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
测试:
root@gjq-virtual-machine:~# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01,mixed mode)
原文链接:https://www.f2er.com/ubuntu/351123.html