tomcat启动寻找JAVA环境

来源:互联网 发布:php类与对象person 编辑:程序博客网 时间:2024/05/19 03:17


step:startup.bat

setlocalrem Guess CATALINA_HOME if not definedset "CURRENT_DIR=%cd%"if not "%CATALINA_HOME%" == "" goto gotHomeset "CATALINA_HOME=%CURRENT_DIR%"if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHomecd ..set "CATALINA_HOME=%cd%"cd "%CURRENT_DIR%":gotHomeif exist "%CATALINA_HOME%\bin\catalina.bat" goto okHomeecho The CATALINA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end:okHomeset "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"rem Check that target executable existsif exist "%EXECUTABLE%" goto okExececho Cannot find "%EXECUTABLE%"echo This file is needed to run this programgoto end:okExecrem Get remaining unshifted command line arguments and save them in theset CMD_LINE_ARGS=:setArgsif ""%1""=="""" goto doneSetArgsset CMD_LINE_ARGS=%CMD_LINE_ARGS% %1shiftgoto setArgs:doneSetArgscall "%EXECUTABLE%" start %CMD_LINE_ARGS%:end
找到catalina的配置信息,紧接着我们可以去catalina.bat看一下

step2:catalina.bat

setlocalrem Suppress Terminate batch job on CTRL+Cif not ""%1"" == ""run"" goto mainEntryif "%TEMP%" == "" goto mainEntryif exist "%TEMP%\%~nx0.run" goto mainEntryecho Y>"%TEMP%\%~nx0.run"if not exist "%TEMP%\%~nx0.run" goto mainEntryecho Y>"%TEMP%\%~nx0.Y"call "%~f0" %* <"%TEMP%\%~nx0.Y"rem Use provided errorlevelset RETVAL=%ERRORLEVEL%del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1exit /B %RETVAL%:mainEntrydel /Q "%TEMP%\%~nx0.run" >NUL 2>&1rem Guess CATALINA_HOME if not definedset "CURRENT_DIR=%cd%"if not "%CATALINA_HOME%" == "" goto gotHomeset "CATALINA_HOME=%CURRENT_DIR%"if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHomecd ..set "CATALINA_HOME=%cd%"cd "%CURRENT_DIR%":gotHomeif exist "%CATALINA_HOME%\bin\catalina.bat" goto okHomeecho The CATALINA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end:okHomerem Copy CATALINA_BASE from CATALINA_HOME if not definedif not "%CATALINA_BASE%" == "" goto gotBaseset "CATALINA_BASE=%CATALINA_HOME%":gotBaserem Ensure that neither CATALINA_HOME nor CATALINA_BASE contains a semi-colonrem as this is used as the separator in the classpath and Java provides norem mechanism for escaping if the same character appears in the path. Check thisrem by replacing all occurrences of ';' with '' and checking that neitherrem CATALINA_HOME nor CATALINA_BASE have changedif "%CATALINA_HOME%" == "%CATALINA_HOME:;=%" goto homeNoSemicolonecho Using CATALINA_HOME:   "%CATALINA_HOME%"echo Unable to start as CATALINA_HOME contains a semicolon (;) charactergoto end:homeNoSemicolonif "%CATALINA_BASE%" == "%CATALINA_BASE:;=%" goto baseNoSemicolonecho Using CATALINA_BASE:   "%CATALINA_BASE%"echo Unable to start as CATALINA_BASE contains a semicolon (;) charactergoto end:baseNoSemicolonrem Ensure that any user defined CLASSPATH variables are not used on startup,rem but allow them to be specified in setenv.bat, in rare case when it is needed.set CLASSPATH=rem Get standard environment variablesif not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHomecall "%CATALINA_BASE%\bin\setenv.bat"goto setenvDone:checkSetenvHomeif exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat":setenvDonerem Get standard Java environment variablesif exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspathecho Cannot find "%CATALINA_HOME%\bin\setclasspath.bat"echo This file is needed to run this programgoto end:okSetclasspathcall "%CATALINA_HOME%\bin\setclasspath.bat" %1if errorlevel 1 goto endrem Add on extra jar file to CLASSPATHrem Note that there are no quotes as we do not want to introduce randomrem quotes into the CLASSPATHif "%CLASSPATH%" == "" goto emptyClasspathset "CLASSPATH=%CLASSPATH%;":emptyClasspathset "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar"if not "%CATALINA_TMPDIR%" == "" goto gotTmpdirset "CATALINA_TMPDIR=%CATALINA_BASE%\temp":gotTmpdir

cataina的系统相关配置完成之后,在这个过程中需要调用名为setclasspath.bat的信息

step3:setclasspath.bat

set "JAVA_HOME=D:\Program Files\Java\jdk1.8.0_101"rem Make sure prerequisite environment variables are setrem In debug mode we need a real JDK (JAVA_HOME)if ""%1"" == ""debug"" goto needJavaHomerem Otherwise either JRE or JDK are fineif not "%JRE_HOME%" == "" goto gotJreHomeif not "%JAVA_HOME%" == "" goto gotJavaHomeecho Neither the JAVA_HOME nor the JRE_HOME environment variable is definedecho At least one of these environment variable is needed to run this programgoto exit:needJavaHomerem Check if we have a usable JDKif "%JAVA_HOME%" == "" goto noJavaHomeif not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHomeif not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHomeif not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHomeif not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHomeset "JRE_HOME=%JAVA_HOME%"goto okJava:noJavaHomeecho The JAVA_HOME environment variable is not defined correctly.echo It is needed to run this program in debug mode.echo NB: JAVA_HOME should point to a JDK not a JRE.goto exit
会在这里寻找JAVA_HOME环境变量设置的路径,在这里我们可以设置


0 0