tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

 

windows系统:

部署了一个Tomcat8.5.15,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。

解决方式:

在setclasspath.bat的开头声明环境变量。如图所示:

先看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=E:\Java\jdk1.8.0_151
set JRE_HOME=E:\Java\jre8

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。控制台窗口关闭后,这两个变量也将消失,不会再占用内存


linux系统:

在tomcat的bin目录下,编辑catalina.sh文件,加入

export JAVA_HOME=/usr/local/java/jdk1.8.0_151

export JRE_HOME=/usr/local/java/jdk1.8.0_151/jre

这两行,重新启动就正常!

 

本章完,个人经验记录,仅供参考!

白驹过隙,当看到比你优秀的人比你还努力的时候,你也会越来越优秀,相信越努力越幸运!

 

转载于:https://www.cnblogs.com/knownfreestyle/p/11383884.html

你可能感兴趣的:(tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined)