查看自带的版本,并卸载(根据个人需求决定是否卸载重新安装)
[root@benson ~]# java -version
java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode)
 [root@benson ~]# rpm -qa|grep java (查出系统自带了哪些JDK rpm, 然后用rmp -e删包)
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
[root@benson ~]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
[root@benson ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
[root@benson ~]# rpm -qa|grep jdk (可以执行以下命令看是否还有一些残留, 将查出来的包用第二步方法删除即可。)
[root@benson ~]# rpm -qa|grep gcj
libgcj-4.1.2-48.el5
[root@benson ~]# rpm -e --nodeps libgcj-4.1.2-48.el5
warning: /usr/lib/security/classpath.security saved as /usr/lib/security/classpath.security.rpmsave
[root@benson ~]# rpm -qa|grep gcj
[root@benson ~]# rpm -qa|grep jdk
[root@benson ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
以上已经删除掉系统自带的jdk包了,下面开始下载新的JDK包并且安装配置。
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
下载jdk
tar -zxvf jdk-7u17-linux-i586.tar.gz
mv  jdk1.7.0_17 /usr/java
[root@benson java]# pwd
/usr/java
[root@benson java]# ls
jdk1.7.0_17
 
修改 /etc/profile在后面加上如下几行
vim /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_17
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME=/usr/java/jdk1.7.0_17
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
再在终端上声明一下
[root@benson ~]# export JAVA_HOME=/usr/java/jdk1.7.0_17
[root@benson ~]# export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@benson ~]# export PATH=$PATH:$JAVA_HOME/bin
[root@benson ~]# java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)
至此jdk已经安装完,显示出来了。
 
卸载重新安装JDK和tomcat_安装JDK解压下载的tomcat
tar -zxvf apache-tomcat-7.0.39.tar.gz
启动tomcat
 [root@benson bin]# pwd
/root/apache-tomcat-7.0.39/bin
[root@benson bin]# ls
bootstrap.jar  catalina-tasks.xml            configtest.bat  daemon.sh   setclasspath.bat  shutdown.sh  tomcat-juli.jar       tool-wrapper.sh
catalina.bat   commons-daemon.jar            configtest.sh   digest.bat  setclasspath.sh   startup.bat  tomcat-native.tar.gz  version.bat
catalina.sh    commons-daemon-native.tar.gz  cpappend.bat    digest.sh   shutdown.bat      startup.sh   tool-wrapper.bat      version.sh
[root@benson bin]# ./startup.sh
Using CATALINA_BASE:   /root/apache-tomcat-7.0.39
Using CATALINA_HOME:   /root/apache-tomcat-7.0.39
Using CATALINA_TMPDIR: /root/apache-tomcat-7.0.39/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_17
Using CLASSPATH:       /root/apache-tomcat-7.0.39/bin/bootstrap.jar:/root/apache-tomcat-7.0.39/bin/tomcat-juli.jar
[root@benson bin]# ps -eaf|grep tomcat
root     22791     1  4 23:15 pts/5    00:00:02 /usr/java/jdk1.7.0_17/bin/java -Djava.util.logging.config.file=/root/apache-tomcat-7.0.39/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/root/apache-tomcat-7.0.39/endorsed -classpath /root/apache-tomcat-7.0.39/bin/bootstrap.jar:/root/apache-tomcat-7.0.39/bin/tomcat-juli.jar -Dcatalina.base=/root/apache-tomcat-7.0.39 -Dcatalina.home=/root/apache-tomcat-7.0.39 -Djava.io.tmpdir=/root/apache-tomcat-7.0.39/temp org.apache.catalina.startup.Bootstrap start
root     22822 21978  0 23:16 pts/5    00:00:00 grep tomcat
[root@benson bin]# ps -eaf|grep 8080
root     22857 21978  0 23:17 pts/5    00:00:00 grep 8080
[root@benson bin]# netstat -an|grep 8080
tcp        0      0 :::8080                     :::*                        LISTEN     
[root@benson bin]# netstat -an|grep 8009
tcp        0      0 :::8009                     :::*                        LISTEN     
在浏览器输入IP:8080即可访问到tomcat页面
卸载重新安装JDK和tomcat_安装JDK_02