1、官网下载jdk-8u45-linux-x64.tar.gz
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2、tar解压:tar -xzvf jdk-8u45-linux-x64.tar.gz
一般安装在/usr/local/目录下
3、配置环境变量:
<span style="white-space:pre"> </span>$ vi /etc/profile
<span style="white-space:pre"> </span>在尾行添加:
<span style="white-space:pre"> </span>#set java environment
export JAVA_HOME=/usr/local/jdk1.8.0_45
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
then : source /etc/profile //让配置立即生效
test : java -version