以jdk1.7.0_71为例:
下载地址:http://pan.baidu.com/s/1mibCpPe
运行以下语句进行安装:
rpm -ivh jdk-7u71-linux-x64.rpm
配置环境变量
编辑/etc/profile文件,在文件尾部增加:
# set Java environment
JAVA_HOME=/usr/java/jdk1.7.0_71
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
重启。
测试
[root@localhost ~]# echo $JAVA_HOME
/usr/java/jdk1.7.0_71
[root@localhost ~]# echo $PATH
/usr/java/jdk1.7.0_71/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# echo $CLASSPATH
.:/usr/java/jdk1.7.0_71/lib/dt.jar:/usr/java/jdk1.7.0_71/lib/tools.jar
[root@localhost ~]# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)