|
我的系统是redhat9.0的,装好jdk和tomcat后我按下面的方法配置环境变量的:
[root@linux-14 root]# vi /etc/profile
INPUTRC=/etc/inputrc
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
#java environment variable settings
JAVA_HOME=/tmp/jdk1.5.0
export JAVA_HOME
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export CLASSPATH
CATALINA_BASE=/tmp/jakarta-tomcat-5.5.5
export CATALINA_BASE
CATALINA_HOME=/tmp/jakarta-tomcat-5.5.5
export CATALINA_HOME
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
之后检查配置结果如下:
[root@linux-14 root]# java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
[root@linux-14 root]# echo $JAVA_HOME
/tmp/jdk1.5.0
[root@linux-14 root]# echo $CLASSPATH
/tmp/jdk1.5.0/lib:/tmp/jdk1.5.0/jre/lib
[root@linux-14 root]# echo $PATH
/tmp/jdk1.5.0/bin:/tmp/jdk1.5.0/jre/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin
[root@linux-14 root]# $CATALINA_HOME/bin/startup.sh #测试tomcat的时候出错了
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
我又编了一个简单的java程序如下:
class test
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
[root@linux-14 root]# javac test.java
[root@linux-14 root]# java test
Exception in thread "main" java.lang.NoClassDefFoundError: test
结果报错,不知道是那边出了问题情大伙儿纠正一下,谢谢! |
|