网上关于在CentOS下安装jdk1.6和Tomcat5.5.23文章有很多,还是给自己一个笔记吧。
环境:CentOS
[root@mdw ~]# uname -a
Linux mdw 2.6.18-92.el5 #1 SMP Tue Jun 10 18:51:06 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
安装jdk1.6
首先下载,下载这块儿我就不多说了,直接到sun网站去下载就是了,是有点慢的,呵呵。
[root@mdw src]# ll
total 84824
drwxr-xr-x 11 root root 4096 Mar 22 15:53 apache-tomcat-5.5.27
-rw-r--r-- 1 root root 6478912 Mar 22 13:52 apache-tomcat-5.5.27.tar.gz
drwxr-xr-x 2 root root 4096 Mar 19 13:33 greenplum-db
-rwxr-xr-x 1 root root 80238916 Mar 22 14:48 jdk-6u12-linux-x64.bin
drwxr-xr-x 3 root root 4096 Mar 19 13:17 kernels
drwxr-xr-x 7 root root 4096 Mar 19 13:21 RedHat
因为我的硬件是dell的2950 64位的,所以安装的CentOS也是64位的,安装的jdk也是64位的。大家根据自己的操作系统进行选择。
我把jdk安装在/usr/local中,把jdk-6u12-linux-x64.bin拷贝到/usr/local当中。
[root@mdw local]# ./jdk-6u12-linux-x64.bin 回车,然后是协议,直接空格过去,然后点击enter,安装完毕。
[root@mdw local]# ll
total 108
drwxr-xr-x 2 root root 4096 Mar 30 2007 bin
drwxr-xr-x 2 root root 4096 Mar 30 2007 etc
drwxr-xr-x 2 root root 4096 Mar 30 2007 games
lrwxrwxrwx 1 gpadmin gpadmin 22 Mar 19 13:37 greenplum-db -> ./greenplum-db-3.2.2.0
drwxr-xr-x 9 gpadmin gpadmin 4096 Mar 19 13:37 greenplum-db-3.2.2.0
drwxr-xr-x 2 root root 4096 Mar 30 2007 include
drwxr-xr-x 10 root root 4096 Mar 22 15:56 jdk1.6.0_12
drwxr-xr-x 2 root root 4096 Mar 30 2007 lib
drwxr-xr-x 2 root root 4096 Mar 30 2007 lib64
drwxr-xr-x 2 root root 4096 Mar 30 2007 libexec
drwxr-xr-x 2 root root 4096 Mar 30 2007 sbin
drwxr-xr-x 4 root root 4096 Mar 19 13:14 share
drwxr-xr-x 2 root root 4096 Mar 30 2007 src
drwxr-xr-x 11 root root 4096 Mar 22 16:20 tomcat
然后在/etc/profile中加入如下代码:
export Java_HOME=/usr/local/jdk1.6.0_12
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
然后重新加载一遍:就出现如下结果,
[root@mdw local]#source /etc/profile(当然可以reboot)
[root@mdw local]# java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)