Tomcat flashed over while booting, but the JDK environment variables are configured correctly and can be run with Java or JAVAC commands, but Tomcat cannot run the solution.

Source: Internet
Author: User
Tags goto

Today, when Tomcat was started while using tomcat6.0.7, the JDK environment variable was configured correctly and could run with either Java or JAVAC commands, but Tomcat could not run the solution.

1. View error messages when you start Tomcat directly on the command line;


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 are 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. According to the above information, configure the Java_home path: such as java_home= "D:\Program Files\java\jdk1.6.0_21\bin"
To configure the JRE path: jre_home= "D:\Program Files\java\jdk1.6.0_21\jre"

3. Restart Tomcat.

4. If the above configuration is complete or cannot start, please see the configuration below. 5. Because Tomcat's Startup.bat started, the call was Catalina.bat, and Catalina.bat called Setclasspath.bat
The configuration in Setclasspath.bat is the jar package required for Tomcat runtime and the classes needed to use it.
The Java_home and Jre_home values are configured at the head of the Setclasspath.bat. As follows:


Set Java_home=d:\program files\java\jdk1.6.0_21
Set Jre_home=d:\program Files\java\jdk1.6.0_21\jre


6. Configure the finish to start Tomcat again.




Setclasspath.bat files are as follows:


@echo off
REM Licensed to the Apache Software Foundation (ASF) under one or more
REM Contributor license agreements. 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 are not to use this file except in compliance with
REM the License. You could obtain a copy of the License at
Rem
REM http://www.apache.org/licenses/LICENSE-2.0
Rem
REM unless required by applicable or agreed to in writing, software
REM distributed under the License is distributed on ' as ' basis,
REM without warranties or CONDITIONS of any KIND, either express or implied.
REM 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 the 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 be needed to run this program
Echo Nb:java_home should 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 be 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 be 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 This is 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.