官网下载
地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html,并选择相应的 .gz
包下载
下载解压都安装目录
sudo tar -zxvf jdk-8u144-linux-x64.tar.gz -C /opt/
设置环境变量
#set oracle jdk environment
export JAVA_HOME=/opt/jdk1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
设置系统默认jdk 版本
sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_144/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_144/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_144/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /opt/jdk1.8.0_144/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /opt/jdk1.8.0_144/bin/javap 300
**初次安装会提示选择版本 **
sudo update-alternatives --config java
测试jdk
java -version