tool-wrapper.bat 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. rem ---------------------------------------------------------------------------
  17. rem Wrapper script for command line tools
  18. rem
  19. rem Environment Variable Prerequisites
  20. rem
  21. rem CATALINA_HOME May point at your Catalina "build" directory.
  22. rem
  23. rem TOOL_OPTS (Optional) Java runtime options.
  24. rem
  25. rem JAVA_HOME Must point at your Java Development Kit installation.
  26. rem Using JRE_HOME instead works as well.
  27. rem
  28. rem JRE_HOME Must point at your Java Runtime installation.
  29. rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
  30. rem are both set, JRE_HOME is used.
  31. rem
  32. rem JAVA_OPTS (Optional) Java runtime options.
  33. rem
  34. rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories
  35. rem containing some jars in order to allow replacement of APIs
  36. rem created outside of the JCP (i.e. DOM and SAX from W3C).
  37. rem It can also be used to update the XML parser implementation.
  38. rem This is only supported for Java <= 8.
  39. rem Defaults to $CATALINA_HOME/endorsed.
  40. rem ---------------------------------------------------------------------------
  41. setlocal
  42. rem Guess CATALINA_HOME if not defined
  43. set "CURRENT_DIR=%cd%"
  44. if not "%CATALINA_HOME%" == "" goto gotHome
  45. set "CATALINA_HOME=%CURRENT_DIR%"
  46. if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome
  47. cd ..
  48. set "CATALINA_HOME=%cd%"
  49. cd "%CURRENT_DIR%"
  50. :gotHome
  51. if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome
  52. echo The CATALINA_HOME environment variable is not defined correctly
  53. echo This environment variable is needed to run this program
  54. goto end
  55. :okHome
  56. rem Ensure that any user defined CLASSPATH variables are not used on startup,
  57. rem but allow them to be specified in setenv.bat, in rare case when it is needed.
  58. set CLASSPATH=
  59. rem Get standard environment variables
  60. if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
  61. rem Get standard Java environment variables
  62. if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath
  63. echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat"
  64. echo This file is needed to run this program
  65. goto end
  66. :okSetclasspath
  67. call "%CATALINA_HOME%\bin\setclasspath.bat" %1
  68. if errorlevel 1 goto end
  69. rem Add on extra jar files to CLASSPATH
  70. rem Note that there are no quotes as we do not want to introduce random
  71. rem quotes into the CLASSPATH
  72. if "%CLASSPATH%" == "" goto emptyClasspath
  73. set "CLASSPATH=%CLASSPATH%;"
  74. :emptyClasspath
  75. set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar;%CATALINA_HOME%\lib\servlet-api.jar;%CATALINA_HOME%\lib\tomcat-util.jar"
  76. set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  77. rem Java 9 no longer supports the java.endorsed.dirs
  78. rem system property. Only try to use it if
  79. rem JAVA_ENDORSED_DIRS was explicitly set
  80. rem or CATALINA_HOME/endorsed exists.
  81. set ENDORSED_PROP=ignore.endorsed.dirs
  82. if "%JAVA_ENDORSED_DIRS%" == "" goto noEndorsedVar
  83. set ENDORSED_PROP=java.endorsed.dirs
  84. goto doneEndorsed
  85. :noEndorsedVar
  86. if not exist "%CATALINA_HOME%\endorsed" goto doneEndorsed
  87. set ENDORSED_PROP=java.endorsed.dirs
  88. :doneEndorsed
  89. rem Get remaining unshifted command line arguments and save them in the
  90. set CMD_LINE_ARGS=
  91. :setArgs
  92. if ""%1""=="""" goto doneSetArgs
  93. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  94. shift
  95. goto setArgs
  96. :doneSetArgs
  97. %_RUNJAVA% %JAVA_OPTS% %TOOL_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %CMD_LINE_ARGS%
  98. :end