Ubuntu 16.04 用apt-get来安装Java

参考:
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

JDK 8 9 11, 任选一个安装

sudo apt-get install oracle-java8-installer # JDK 8
sudo apt-get install oracle-java9-installer # JDK 9
sudo apt-get install oracle-java11-installer # JDK 11

配置环境变量:

sudo vim /etc/environment
JAVA_HOME="/usr/lib/jvm/java-8-oracle" # 文件最后加上

保存退出

source /etc/environment

END

你可能感兴趣的:(Java,ubuntu)