您的位置:首页 > 运维架构 > Tomcat

Tomcat启动时一闪而过,但是jdk环境变量配置正确,并使用java或者javac命令多可以运行,但是tomcat不能运行解决办法。

2013-09-21 11:40 1186 查看
今天在使用tomcat6.0.7时出现Tomcat启动时一闪而过,但是jdk环境变量配置正确,并使用java或者javac命令多可以运行,但是tomcat不能运行解决办法。

1.在命令行中直接启动tomcat时查看错误信息 如;

C:\Users\Administrator>

C:\Users\Administrator>cd D:\apache-tomcat-6.0.37\bin

C:\Users\Administrator>d:

D:\apache-tomcat-6.0.37\bin>startup.bat

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

D:\apache-tomcat-6.0.37\bin>

D:\apache-tomcat-6.0.37\bin>

2.根据以上信息,配置java_home路径:如java_home="D:\Program Files\java\jdk1.6.0_21\bin"

配置jre路径: jre_home="D:\Program Files\java\jdk1.6.0_21\jre"

3.重新启动tomcat。

4.如果以上配置完成还是不能启动,请看下面配置.

5.由于tomcat的startup.bat启动时,调用的是catalina.bat ,而catalina.bat调用了setclasspath.bat

在setclasspath.bat中配置的就是tomcat运行时所需的jar包及使用所需的类。

在setclasspath.bat的头部配置JAVA_HOME和JRE_HOME的值。如下:

set JAVA_HOME=D:\Program Files\java\jdk1.6.0_21

set JRE_HOME=D:\Program Files\java\jdk1.6.0_21\jre

6.配置完成再次启动tomcat即可。

setclasspath.bat文件如下:

@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more

rem contributor license agreements. See the NOTICE file distributed with

rem this work for additional information regarding copyright ownership.

rem The ASF licenses this file to You under the Apache License, Version 2.0

rem (the "License"); you may not use this file except in compliance with

rem the License. You may obtain a copy of the License at

rem

rem http://www.apache.org/licenses/LICENSE-2.0
rem

rem Unless required by applicable law or agreed to in writing, software

rem distributed under the License is distributed on an "AS IS" BASIS,

rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

rem See the License for the specific language governing permissions and

rem limitations under the License.

rem ---------------------------------------------------------------------------

rem Set CLASSPATH and Java options

rem

rem $Id: setclasspath.bat 908749 2010-02-10 23:26:42Z markt $

rem ---------------------------------------------------------------------------

set JAVA_HOME=D:\Program Files\java\jdk1.6.0_21

set JRE_HOME=D:\Program Files\java\jdk1.6.0_21\jre

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 "%BASEDIR%" == "" 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 "%BASEDIR%\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 Don't override the endorsed dir if the user has set it previously

if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir

rem Set the default -Djava.endorsed.dirs argument

set "JAVA_ENDORSED_DIRS=%BASEDIR%\endorsed"

:gotEndorseddir

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 _RUNJDB="%JAVA_HOME%\bin\jdb"

goto end

:exit

exit /b 1

:end

exit /b 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐