1、官网下载jdk-7u45-linux-x64.tar.gz
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2、tar解压:tar -xzvf jdk-7u45-linux-x64.tar.gz
一般安装在/usr/local/目录下
3、配置环境变量:
<span style="font-size:18px;">$ vi /etc/profile</span>
<span style="font-size:18px;">在尾行添加:</span>
<span style="font-size:18px;">#set java environment export JAVA_HOME=/usr/local/jdk1.7.0_45 export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin</span>
<span style="font-size:18px;">4、使配置生效:</span>
<span style="font-size:18px;">#source /etc/profile</span>
<span style="font-size:18px;">5、检验是否安装成功:</span>
<span style="font-size:18px;">#java -version</span>
<span style="font-size:18px;">出现版本信息说明安装成功:</span>
<span style="font-size:18px;">#java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)</span></span>
<span style="font-size:18px;">结束。</span>