当前位置:Linux教程 - Linux资讯 - 详细讲解Linux系统下JDK、Tomcat的安装

详细讲解Linux系统下JDK、Tomcat的安装

本文详细讲解Linux系统下JDK、Tomcat的安装

Jdk安装:

[root@b home]# ls

jdk-1_5_0_12-linux-i586-rpm.bin lost+found Oracle

1、将jdk进行解压

[root@b home]# ./jdk-1_5_0_12-linux-i586-rpm.bin

2、将解压文件copy到/usr/Java下

[root@b home]# cp jdk-1_5_0_12-linux-i586.rpm /usr/java

[root@b home]# cd /usr/java

3、进行安装

[root@b java]# rpm -ivh jdk-1_5_0_12-linux-i586.rpm

Preparing... (########################################### [100%]

package jdk-1.5.0_12-fcs is already installed

4、将环境变量加入到profile中,如果写入到(/etc/profile)对所有用户都生效,如果只对某个用户生效写入到(/home/username/profile)中

eXPort JAVA_HOME = /usr/java/jdk1.5

export PATH = $PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

exportCLASSPATH=.:/usr/java/jdk1.5/lib:/usr/java/jdk1.5/jre/lib:$CLASSPATH

5、验证安装结果

[root@b java]# java -version

-bash: java: command not found

错误原因是环境变量未生效。

[root@b java]# source /etc/profile

[root@b java]# java -version

java version "1.5.0_12"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)

Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)

至此安装成功。

jdk下载地址:http://java.sun.com/javase/downloads/index_jdk5.jsp

Tomcat安装:

1、将文件copy到/usr/local下解压安装文件

[root@b local]# tar -zxvf apache-tomcat-5.5.23.tar.gz

[root@b local]# ls

apache-tomcat-5.5.23 bin games lib man share

apache-tomcat-5.5.23.tar.gz etc include libexec sbin src

[root@b local]# cd ~

2、加入环境变量

[root@b root]# vi .bashrc

export JAVA_HOME=/usr/java/jdk1.5.0_12

export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

export CATALINA_BASE=/usr/local/apache-tomcat-5.5.23

export CATALINA_HOME=/usr/local/apache-tomcat-5.5.23

3、使环境变量生效

[root@b root]# source .bashrc

4、验证安装结果

[root@b root]# echo $JAVA_HOME

/usr/java/jdk1.5.0_12

[root@b root]# echo $CATALINA_HOME

/usr/local/apache-tomcat-5.5.23

[root@b root]#

(出处:http://www.sheup.com/)