1、下载要安装的jdk的版本并上传到系统中;
2、解压缩到指定的目录下;
[root@localhost /]# tar -zxvf jdk-7u45-linux-x64.tar.gz
[root@localhost /]# mkdir java
[root@localhost /]# mv /usr/local/src/jdk1.7.0_45/ /usr/java/
3、修改配置文件并生效;
[root@localhost /]# vi /etc/profile
[root@localhost /]#
[root@localhost /]# source /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_45
JRE_HOME=/usr/java/jdk1.7.0_45/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
4、验证;
[root@localhost /]# java -version
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)
[root@localhost /]#