当前位置: 移动技术网 > IT编程>网络>Dos/Bat > windows下直接点击startup.bat启动tomcat服务示例代码

windows下直接点击startup.bat启动tomcat服务示例代码

2017年12月08日  | 移动技术网IT编程  | 我要评论
在xp上明明已经安装了jdk1.5并设置好了java_home,可偏偏tomcat在启动过程中找不到。 报错信息如下:neither the java_home nor t
在xp上明明已经安装了jdk1.5并设置好了java_home,可偏偏tomcat在启动过程中找不到。

报错信息如下: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路径,何解?

原因不知道了,下面来看解决办法:

1、分析startup.bat启动脚本:发现其调用了catalina.bat,而catalina.bat调用了setclasspath.bat

2、在setclasspath.bat的头部定义了java_home和jre_home的值,那么在这里手动设置java_home变量
复制代码 代码如下:

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.5.0_05

set jre_home=c:\program files\java\jre1.5.0_05

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

:gotjrehome

if not exist "%jre_home%\bin\java.exe" goto nojavahome

if not exist "%jre_home%\bin\javaw.exe" goto nojavahome

if not ""%1"" == ""debug"" goto okjavahome

echo java_home should point to a jdk in order to run in debug mode.

goto exit

:gotjdkhome

if not exist "%java_home%\bin\java.exe" goto nojavahome

if not exist "%java_home%\bin\javaw.exe" goto nojavahome

if not exist "%java_home%\bin\jdb.exe" goto nojavahome

if not exist "%java_home%\bin\javac.exe" goto nojavahome

if not "%jre_home%" == "" goto okjavahome

set jre_home=%java_home%

goto okjavahome

:nojavahome

echo the java_home environment variable is not defined correctly

echo this environment variable is needed to run this program

echo nb: java_home should point to a jdk not a jre

goto exit

:okjavahome

if not "?sedir%" == "" goto gotbasedir

echo the basedir environment variable is not defined

echo this environment variable is needed to run this program

goto exit

:gotbasedir

if exist "?sedir%\bin\setclasspath.bat" goto okbasedir

echo the basedir environment variable is not defined correctly

echo this environment variable is needed to run this program

goto exit

:okbasedir

rem set the default -djava.endorsed.dirs argument

set java_endorsed_dirs=?sedir%\endorsed

rem set standard classpath

rem note that there are no quotes as we do not want to introduce random

rem quotes into the classpath

if not exist "%java_home%\bin\tools.jar" goto nojavac

set classpath=%java_home%\lib\tools.jar

:nojavac

rem set standard command for invoking java.

rem note that nt requires a window name argument when using start.

rem also note the quoting as java_home may contain spaces.

set _runjava="%jre_home%\bin\java"

set _runjavaw="%jre_home%\bin\javaw"

set _runjdb="%java_home%\bin\jdb"

set _runjavac="%java_home%\bin\javac"

goto end

:exit

exit /b 1

:end

3、重启tomcat,敲入http://localhost:8080验证,问题解决。

tomcat5需要jdk1.6做支撑,jdk1.5不能够。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网