setclasspath.bat 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
  18. rem are valid and consistent with the selected start-up options and set up the
  19. rem endorsed directory.
  20. rem ---------------------------------------------------------------------------
  21. rem Make sure prerequisite environment variables are set
  22. rem In debug mode we need a real JDK (JAVA_HOME)
  23. if ""%1"" == ""debug"" goto needJavaHome
  24. rem Otherwise either JRE or JDK are fine
  25. if not "%JRE_HOME%" == "" goto gotJreHome
  26. if not "%JAVA_HOME%" == "" goto gotJavaHome
  27. echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
  28. echo At least one of these environment variable is needed to run this program
  29. goto exit
  30. :needJavaHome
  31. rem Check if we have a usable JDK
  32. if "%JAVA_HOME%" == "" goto noJavaHome
  33. if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
  34. if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
  35. if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
  36. set "JRE_HOME=%JAVA_HOME%"
  37. goto okJava
  38. :noJavaHome
  39. echo The JAVA_HOME environment variable is not defined correctly.
  40. echo It is needed to run this program in debug mode.
  41. echo NB: JAVA_HOME should point to a JDK not a JRE.
  42. goto exit
  43. :gotJavaHome
  44. rem No JRE given, use JAVA_HOME as JRE_HOME
  45. set "JRE_HOME=%JAVA_HOME%"
  46. :gotJreHome
  47. rem Check if we have a usable JRE
  48. if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome
  49. goto okJava
  50. :noJreHome
  51. rem Needed at least a JRE
  52. echo The JRE_HOME environment variable is not defined correctly
  53. echo This environment variable is needed to run this program
  54. goto exit
  55. :okJava
  56. rem Don't override the endorsed dir if the user has set it previously
  57. if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir
  58. rem Java 9 no longer supports the java.endorsed.dirs
  59. rem system property. Only try to use it if
  60. rem CATALINA_HOME/endorsed exists.
  61. if not exist "%CATALINA_HOME%\endorsed" goto gotEndorseddir
  62. set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed"
  63. :gotEndorseddir
  64. rem Don't override _RUNJAVA if the user has set it previously
  65. if not "%_RUNJAVA%" == "" goto gotRunJava
  66. rem Set standard command for invoking Java.
  67. rem Also note the quoting as JRE_HOME may contain spaces.
  68. set _RUNJAVA="%JRE_HOME%\bin\java.exe"
  69. :gotRunJava
  70. rem Don't override _RUNJDB if the user has set it previously
  71. rem Also note the quoting as JAVA_HOME may contain spaces.
  72. if not "%_RUNJDB%" == "" goto gotRunJdb
  73. set _RUNJDB="%JAVA_HOME%\bin\jdb.exe"
  74. :gotRunJdb
  75. goto end
  76. :exit
  77. exit /b 1
  78. :end
  79. exit /b 0