说明:
实现: 2. 检查linux系统上是否存在其它版本的JDK,如果有则先卸载旧版本的JKD。 # java -version java version "1.4.2" gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-51) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 查看自带的JDK的相关信息 # rpm -qa | grep java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 卸载自带的JDK的信息 # rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
# chmod +x jdk-7u25-linux-x64.rpm # rpm -ivh jdk-7u25-linux-x64.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar...
# mkdir /usr/java //新建文件夹/usr/java/ # tar xzvf jdk-7u25-linux-x64.tar.gz -C /usr/java/
# vim /etc/profile //添加以下内容 export JAVA_HOME=/usr/java/jdk1.7.0_25 export CLASSPATH=/usr/java/jdk1.7.0_25/lib export PATH=$JAVA_HOME/bin:$PATH # source /etc/profile //用命令source /etc/profile使配置文件立即生效。否则只能重启系统才能使配置参数生效
# echo $JAVA_HOME /usr/java/jdk1.7.0_25 # echo $PATH /usr/java/jdk1.7.0_25/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin # echo $CLASSPATH /usr/java/jdk1.7.0_25/lib
# 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)
|