startup.bat文件的主要做用就是找到catali.bat文件,而且执行它。java
@echo offexpress
rem -----------------------------------------------------------------------------------------------------------------------apache
/*windows
dos在运行批处理时,会依次执行批处理中的每条命令,而且会显示在显示器上,若是你不想让他们显示,能够加一个echo off。固然echo off自己也是一条命令,若是本条命令也不肯意显示,能够在echo off前面加@数组
*/tomcat
rem -----------------------------------------------------------------------------------------------------------------------
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.app
/*less
rem为注释ui
*/this
rem -----------------------------------------------------------------------------------------------------------------------
if "%OS%" == "Windows_NT" setlocal
/*
判断当前系统是否为windows
*/
rem -----------------------------------------------------------------------------------------------------------------------
set "CURRENT_DIR=%cd%"
/*
设置当前目录
*/
rem -----------------------------------------------------------------------------------------------------------------------
if not "%CATALINA_HOME%" == "" goto gotHome
/*
若是设置了CATALINA_HOME环境变量,就知道跳到下面的gotHome处执行
*/
set "CATALINA_HOME=%CURRENT_DIR%"
/*
若是没有设置CATALINA_HOME环境变量,则设置环境变量为当前目录
*/
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
/*
判断一下catalina.bat是否找到了,若是找到了,直接跳到oKHome
*/
cd ..
/*
这里系统假设你开始已经进入了tomcat的bin目录,因此就退到上一级目录
*/
set "CATALINA_HOME=%cd%"
/*
如今再次设置CATALINA_HOME为tomcat的安装目录
*/
cd "%CURRENT_DIR%"
/*
进入dos的当前目录
*/
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
/*
判断一下catalina.bat是否找到了,若是找到了,直接跳到oKHome
*/
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
/*
若是仍是找不到catalina.bat,则给出报错提示
*/
:okHome
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_16/*若是本机已经启动了其余tomcat,则能够经过设置java_home来运行第二个tomcat*/
set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"/*设置要运行的文件*/
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
/*
再次判断catalina.bat是都存在,若是有的话就跳转到okexec执行,不然给出报错提示
*/
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=这里是设置参数
:setArgs
if ""%1""=="""" goto doneSetArgs判断参数是否添加完成
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1//将参数组成一行,接在后面
shift
goto setArgs
:doneSetArgs
call "%EXECUTABLE%" start %CMD_LINE_ARGS%执行catalina.bat文件,将
:end