Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 错误解决


下载好Tomcat,跑到bin 点击startup.bat或 ./startup.sh (linux下执行)就去执行,结果提示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。

看问题就 SDK问题,那么就去下载个最新版本的JDK,
安装完成之后却还是提示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。搞得对Tomcat的学习热情冷了一半。

原因是后来较新版本的JDK(例如我使用的JDK1.7)安装完不会自动登记环境变量JAVA_HOME,JRE_HOME。像我在单位的环境,我的用户是受限制的(PowerUser),不方便设环境变量,于是我就找到了另外一个方法。

先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.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.7.0_02
set JRE_HOME=C:/Program Files/Java/jre7

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

声明:大家学-卢卫湘|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 错误解决


深圳软件开发、app开发、深圳seo