Neither the JAVA_HOME or the JRE_HOME environmental variable is defined

从tomcat的bin目录下启动startup.bat 结果tomcat一闪而过,留下华丽的身影,为什么呢?先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量,如我的就是:

先讲一个Tomcat的问题。到bin看到一个startup.bat就去执行,结果提示

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program



原因是后来较新版本安装完不会自动登记环境变量JAVA_HOME,JRE_HOME。
先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量(红色两行),如我的就是:

只要在setclasspath.bat的开头声明环境变量,如我的就是:

rem ---------------------------------------------------------------------------
rem Set CLASSPATH and Java options
rem
rem $Id: setclasspath.bat 505241 2007-02-09 10:22:58Z jfclere $
rem ---------------------------------------------------------------------------

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20

set JRE_HOME=C:\Program Files\Java\jre6


rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit
......

这样在每次运行startup.bat时就自动注册了JAVA_HOME,JRE_HOME。

运行startup.bat,提示“信息:Server startup in xxxxx ms”  OK 大功告成。

猜你喜欢

转载自liuqing9382.iteye.com/blog/1680593