blob: 366912ba5fd23de072a52d8623ba934cad50563f [file] [log] [blame]
Cheng Tang697ce242014-04-27 16:18:17 +08001@echo off
2rem Licensed to the Apache Software Foundation (ASF) under one or more
3rem contributor license agreements. See the NOTICE file distributed with
4rem this work for additional information regarding copyright ownership.
5rem The ASF licenses this file to You under the Apache License, Version 2.0
6rem (the "License"); you may not use this file except in compliance with
7rem the License. You may obtain a copy of the License at
8rem
9rem http://www.apache.org/licenses/LICENSE-2.0
10rem
11rem Unless required by applicable law or agreed to in writing, software
12rem distributed under the License is distributed on an "AS IS" BASIS,
13rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14rem See the License for the specific language governing permissions and
15rem limitations under the License.
16
17rem ---------------------------------------------------------------------------
18rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
19rem are valid and consistent with the selected start-up options and set up the
20rem endorsed directory.
21rem
22rem $Id: setclasspath.bat 1202062 2011-11-15 06:50:02Z mturk $
23rem ---------------------------------------------------------------------------
24
25rem Make sure prerequisite environment variables are set
26
27rem In debug mode we need a real JDK (JAVA_HOME)
28if ""%1"" == ""debug"" goto needJavaHome
29
30rem Otherwise either JRE or JDK are fine
31if not "%JRE_HOME%" == "" goto gotJreHome
32if not "%JAVA_HOME%" == "" goto gotJavaHome
33echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
34echo At least one of these environment variable is needed to run this program
35goto exit
36
37:needJavaHome
38rem Check if we have a usable JDK
39if "%JAVA_HOME%" == "" goto noJavaHome
40if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
41if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
42if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
43if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
44set "JRE_HOME=%JAVA_HOME%"
45goto okJava
46
47:noJavaHome
48echo The JAVA_HOME environment variable is not defined correctly.
49echo It is needed to run this program in debug mode.
50echo NB: JAVA_HOME should point to a JDK not a JRE.
51goto exit
52
53:gotJavaHome
54rem No JRE given, use JAVA_HOME as JRE_HOME
55set "JRE_HOME=%JAVA_HOME%"
56
57:gotJreHome
58rem Check if we have a usable JRE
59if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome
60if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome
61goto okJava
62
63:noJreHome
64rem Needed at least a JRE
65echo The JRE_HOME environment variable is not defined correctly
66echo This environment variable is needed to run this program
67goto exit
68
69:okJava
70rem Don't override the endorsed dir if the user has set it previously
71if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir
72rem Set the default -Djava.endorsed.dirs argument
73set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed"
74:gotEndorseddir
75
76rem Set standard command for invoking Java.
77rem Note that NT requires a window name argument when using start.
78rem Also note the quoting as JAVA_HOME may contain spaces.
79set _RUNJAVA="%JRE_HOME%\bin\java"
80set _RUNJDB="%JAVA_HOME%\bin\jdb"
81
82goto end
83
84:exit
85exit /b 1
86
87:end
88exit /b 0