一、下载JDK
$wget http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz?AuthParam=1482632646_ad9351bd7d6ed6a663ca89f2058221c8
$mv jdk-8u111-linux-x64.tar.gz\?AuthParam\=1482632646_ad9351bd7d6ed6a663ca89f2058221c8 jdk-8u111-linux-x64.tar.gz
二、解压
$tar -zxvf jdk-8u111-linux-x64.tar.gz
$sudo mkdir /opt/java
$sudo mv jdk1.8.0_111 /opt/java/
三、配置环境变量
$sudo vim /etc/profile
添加
export JAVA_HOME=/opt/java/jdk1.8.0_111
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
立即更新
$source /etc/profile
$java -version
$java
$javac