1下载jdk
[root@localhost opt]# cd soft_bak/
[root@localhost soft_bak]# ls
jdk1.7.0_25.zip postgresql-9.4.5 postgresql-9.4.5.tar.bz2
2解压jdk
[root@localhost soft_bak]# unzip jdk1.7.0_25.zip
[root@localhost soft_bak]# ls
jdk1.7.0_25 jdk1.7.0_25.zip postgresql-9.4.5 postgresql-9.4.5.tar.bz2
3移动jdk到自己制定的目录
[root@localhost soft_bak]# mv jdk1.7.0_25 /usr/local/jdk7
4添加jdk7的路径
vim /etc/profile
JAVA_HOME=/usr/local/jdk7
JRE_HOME=/usr/local/jdk7/jre
PATH=$JAVA_HOME/bin:JRE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
5使更改后的profile生效
source /etc/profile
or
sysctl -p
6验证安装的java版本
[root@localhost jdk7]# java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)