Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 771 | blopes | 1 | @echo off |
| 2 | rem Licensed to the Apache Software Foundation (ASF) under one or more |
||
| 3 | rem contributor license agreements. See the NOTICE file distributed with |
||
| 4 | rem this work for additional information regarding copyright ownership. |
||
| 5 | rem The ASF licenses this file to You under the Apache License, Version 2.0 |
||
| 6 | rem (the "License"); you may not use this file except in compliance with |
||
| 7 | rem the License. You may obtain a copy of the License at |
||
| 8 | rem |
||
| 9 | rem http://www.apache.org/licenses/LICENSE-2.0 |
||
| 10 | rem |
||
| 11 | rem Unless required by applicable law or agreed to in writing, software |
||
| 12 | rem distributed under the License is distributed on an "AS IS" BASIS, |
||
| 13 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
| 14 | rem See the License for the specific language governing permissions and |
||
| 15 | rem limitations under the License. |
||
| 16 | |||
| 17 | rem --------------------------------------------------------------------------- |
||
| 18 | rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings |
||
| 19 | rem are valid and consistent with the selected start-up options and set up the |
||
| 20 | rem endorsed directory. |
||
| 21 | rem --------------------------------------------------------------------------- |
||
| 22 | |||
| 23 | rem Make sure prerequisite environment variables are set |
||
| 24 | |||
| 25 | rem In debug mode we need a real JDK (JAVA_HOME) |
||
| 26 | if ""%1"" == ""debug"" goto needJavaHome |
||
| 27 | |||
| 28 | rem Otherwise either JRE or JDK are fine |
||
| 29 | if not "%JRE_HOME%" == "" goto gotJreHome |
||
| 30 | if not "%JAVA_HOME%" == "" goto gotJavaHome |
||
| 31 | echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined |
||
| 32 | echo At least one of these environment variable is needed to run this program |
||
| 33 | goto exit |
||
| 34 | |||
| 35 | :needJavaHome |
||
| 36 | rem Check if we have a usable JDK |
||
| 37 | if "%JAVA_HOME%" == "" goto noJavaHome |
||
| 38 | if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome |
||
| 39 | if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome |
||
| 40 | if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome |
||
| 41 | set "JRE_HOME=%JAVA_HOME%" |
||
| 42 | goto okJava |
||
| 43 | |||
| 44 | :noJavaHome |
||
| 45 | echo The JAVA_HOME environment variable is not defined correctly. |
||
| 46 | echo JAVA_HOME=%JAVA_HOME% |
||
| 47 | echo It is needed to run this program in debug mode. |
||
| 48 | echo NB: JAVA_HOME should point to a JDK not a JRE. |
||
| 49 | goto exit |
||
| 50 | |||
| 51 | :gotJavaHome |
||
| 52 | rem No JRE given, check if JAVA_HOME is usable as JRE_HOME |
||
| 53 | if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHomeAsJre |
||
| 54 | rem Use JAVA_HOME as JRE_HOME |
||
| 55 | set "JRE_HOME=%JAVA_HOME%" |
||
| 56 | goto okJava |
||
| 57 | |||
| 58 | :noJavaHomeAsJre |
||
| 59 | echo The JAVA_HOME environment variable is not defined correctly. |
||
| 60 | echo JAVA_HOME=%JAVA_HOME% |
||
| 61 | echo NB: JAVA_HOME should point to a JDK not a JRE. |
||
| 62 | goto exit |
||
| 63 | |||
| 64 | :gotJreHome |
||
| 65 | rem Check if we have a usable JRE |
||
| 66 | if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome |
||
| 67 | goto okJava |
||
| 68 | |||
| 69 | :noJreHome |
||
| 70 | rem Needed at least a JRE |
||
| 71 | echo The JRE_HOME environment variable is not defined correctly |
||
| 72 | echo JRE_HOME=%JRE_HOME% |
||
| 73 | echo This environment variable is needed to run this program |
||
| 74 | goto exit |
||
| 75 | |||
| 76 | :okJava |
||
| 77 | rem Don't override the endorsed dir if the user has set it previously |
||
| 78 | if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir |
||
| 79 | rem Java 9 no longer supports the java.endorsed.dirs |
||
| 80 | rem system property. Only try to use it if |
||
| 81 | rem CATALINA_HOME/endorsed exists. |
||
| 82 | if not exist "%CATALINA_HOME%\endorsed" goto gotEndorseddir |
||
| 83 | set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed" |
||
| 84 | :gotEndorseddir |
||
| 85 | |||
| 86 | rem Don't override _RUNJAVA if the user has set it previously |
||
| 87 | if not "%_RUNJAVA%" == "" goto gotRunJava |
||
| 88 | rem Set standard command for invoking Java. |
||
| 89 | rem Also note the quoting as JRE_HOME may contain spaces. |
||
| 90 | set "_RUNJAVA=%JRE_HOME%\bin\java.exe" |
||
| 91 | :gotRunJava |
||
| 92 | |||
| 93 | rem Don't override _RUNJDB if the user has set it previously |
||
| 94 | rem Also note the quoting as JAVA_HOME may contain spaces. |
||
| 95 | if not "%_RUNJDB%" == "" goto gotRunJdb |
||
| 96 | set "_RUNJDB=%JAVA_HOME%\bin\jdb.exe" |
||
| 97 | :gotRunJdb |
||
| 98 | |||
| 99 | goto end |
||
| 100 | |||
| 101 | :exit |
||
| 102 | exit /b 1 |
||
| 103 | |||
| 104 | :end |
||
| 105 | exit /b 0 |