blob: 2cf4610aad6a218c185c52ad750b47dbd7476d20 [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +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 ---------------------------------------------------------------------------
刘洪青6266f992017-05-15 21:21:03 +080018rem 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.
Hongqing Liufd5ee812014-05-10 16:32:51 +080021rem ---------------------------------------------------------------------------
22
23rem Make sure prerequisite environment variables are set
刘洪青6266f992017-05-15 21:21:03 +080024
25rem In debug mode we need a real JDK (JAVA_HOME)
26if ""%1"" == ""debug"" goto needJavaHome
27
28rem Otherwise either JRE or JDK are fine
Hongqing Liufd5ee812014-05-10 16:32:51 +080029if not "%JRE_HOME%" == "" goto gotJreHome
刘洪青6266f992017-05-15 21:21:03 +080030if not "%JAVA_HOME%" == "" goto gotJavaHome
Hongqing Liufd5ee812014-05-10 16:32:51 +080031echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
32echo At least one of these environment variable is needed to run this program
33goto exit
34
刘洪青6266f992017-05-15 21:21:03 +080035:needJavaHome
36rem Check if we have a usable JDK
37if "%JAVA_HOME%" == "" goto noJavaHome
Hongqing Liufd5ee812014-05-10 16:32:51 +080038if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
39if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
40if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
41if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
Hongqing Liufd5ee812014-05-10 16:32:51 +080042set "JRE_HOME=%JAVA_HOME%"
刘洪青6266f992017-05-15 21:21:03 +080043goto okJava
Hongqing Liufd5ee812014-05-10 16:32:51 +080044
45:noJavaHome
刘洪青6266f992017-05-15 21:21:03 +080046echo The JAVA_HOME environment variable is not defined correctly.
47echo It is needed to run this program in debug mode.
48echo NB: JAVA_HOME should point to a JDK not a JRE.
Hongqing Liufd5ee812014-05-10 16:32:51 +080049goto exit
Hongqing Liufd5ee812014-05-10 16:32:51 +080050
刘洪青6266f992017-05-15 21:21:03 +080051:gotJavaHome
52rem No JRE given, use JAVA_HOME as JRE_HOME
53set "JRE_HOME=%JAVA_HOME%"
Hongqing Liufd5ee812014-05-10 16:32:51 +080054
刘洪青6266f992017-05-15 21:21:03 +080055:gotJreHome
56rem Check if we have a usable JRE
57if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome
58if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome
59goto okJava
60
61:noJreHome
62rem Needed at least a JRE
63echo The JRE_HOME environment variable is not defined correctly
64echo This environment variable is needed to run this program
65goto exit
66
67:okJava
Hongqing Liufd5ee812014-05-10 16:32:51 +080068rem Don't override the endorsed dir if the user has set it previously
69if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir
刘洪青a78cd382018-03-01 14:48:24 +080070rem Java 9 no longer supports the java.endorsed.dirs
71rem system property. Only try to use it if
72rem CATALINA_HOME/endorsed exists.
73if not exist "%CATALINA_HOME%\endorsed" goto gotEndorseddir
刘洪青6266f992017-05-15 21:21:03 +080074set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed"
Hongqing Liufd5ee812014-05-10 16:32:51 +080075:gotEndorseddir
76
刘洪青6266f992017-05-15 21:21:03 +080077rem Don't override _RUNJAVA if the user has set it previously
78if not "%_RUNJAVA%" == "" goto gotRunJava
Hongqing Liufd5ee812014-05-10 16:32:51 +080079rem Set standard command for invoking Java.
刘洪青6266f992017-05-15 21:21:03 +080080rem Also note the quoting as JRE_HOME may contain spaces.
81set _RUNJAVA="%JRE_HOME%\bin\java.exe"
82:gotRunJava
83
84rem Don't override _RUNJDB if the user has set it previously
Hongqing Liufd5ee812014-05-10 16:32:51 +080085rem Also note the quoting as JAVA_HOME may contain spaces.
刘洪青6266f992017-05-15 21:21:03 +080086if not "%_RUNJDB%" == "" goto gotRunJdb
87set _RUNJDB="%JAVA_HOME%\bin\jdb.exe"
88:gotRunJdb
Hongqing Liufd5ee812014-05-10 16:32:51 +080089
90goto end
91
92:exit
93exit /b 1
94
95:end
96exit /b 0