windows下tomcat開機啟動設定

來源:互聯網
上載者:User

設定環境變數 CATALINA_HOME

 

比如說:D:/apache-tomcat-5.5.20/bin

 

執行 service.bat install/remove

 

service.bat 代碼如下:

 

@echo off<br />if "%OS%" == "Windows_NT" setlocal<br />rem ---------------------------------------------------------------------------<br />rem NT Service Install/Uninstall script<br />rem<br />rem Options<br />rem install Install the service using Tomcat5 as service name.<br />rem Service is installed using default settings.<br />rem remove Remove the service from the System.<br />rem<br />rem name (optional) If the second argument is present it is considered<br />rem to be new service name<br />rem<br />rem $Id: service.bat 414655 2006-06-15 18:56:42Z yoavs $<br />rem ---------------------------------------------------------------------------</p><p>rem Guess CATALINA_HOME if not defined<br />set CURRENT_DIR=%cd%<br />if not "%CATALINA_HOME%" == "" goto gotHome<br />set CATALINA_HOME=%cd%<br />if exist "%CATALINA_HOME%/bin/tomcat5.exe" goto okHome<br />rem CD to the upper dir<br />cd ..<br />set CATALINA_HOME=%cd%<br />:gotHome<br />if exist "%CATALINA_HOME%/bin/tomcat5.exe" goto okHome<br />echo The tomcat.exe was not found...<br />echo The CATALINA_HOME environment variable is not defined correctly.<br />echo This environment variable is needed to run this program<br />goto end<br />rem Make sure prerequisite environment variables are set<br />if not "%JAVA_HOME%" == "" goto okHome<br />echo The JAVA_HOME environment variable is not defined<br />echo This environment variable is needed to run this program<br />goto end<br />:okHome<br />if not "%CATALINA_BASE%" == "" goto gotBase<br />set CATALINA_BASE=%CATALINA_HOME%<br />:gotBase</p><p>set EXECUTABLE=%CATALINA_HOME%/bin/tomcat5.exe</p><p>rem Set default Service name<br />set SERVICE_NAME=Tomcat5<br />set PR_DISPLAYNAME=Apache Tomcat</p><p>if "%1" == "" goto displayUsage<br />if "%2" == "" goto setServiceName<br />set SERVICE_NAME=%2<br />set PR_DISPLAYNAME=Apache Tomcat %2<br />:setServiceName<br />if %1 == install goto doInstall<br />if %1 == remove goto doRemove<br />if %1 == uninstall goto doRemove<br />echo Unknown parameter "%1"<br />:displayUsage<br />echo.<br />echo Usage: service.bat install/remove [service_name]<br />goto end</p><p>:doRemove<br />rem Remove the service<br />"%EXECUTABLE%" //DS//%SERVICE_NAME%<br />echo The service '%SERVICE_NAME%' has been removed<br />goto end</p><p>:doInstall<br />rem Install the service<br />echo Installing the service '%SERVICE_NAME%' ...<br />echo Using CATALINA_HOME: %CATALINA_HOME%<br />echo Using CATALINA_BASE: %CATALINA_BASE%<br />echo Using JAVA_HOME: %JAVA_HOME%</p><p>rem Use the environment variables as an example<br />rem Each command line option is prefixed with PR_</p><p>set PR_DESCRIPTION=Apache Tomcat Server - http://tomcat.apache.org<br />set PR_INSTALL=%EXECUTABLE%<br />set PR_LOGPATH=%CATALINA_BASE%/logs<br />set PR_CLASSPATH=%CATALINA_HOME%/bin/bootstrap.jar</p><p>rem Set the server jvm from JAVA_HOME<br />set PR_JVM=%JAVA_HOME%/jre/bin/server/jvm.dll<br />if exist "%PR_JVM%" goto foundJvm<br />rem Set the client jvm from JAVA_HOME<br />set PR_JVM=%JAVA_HOME%/jre/bin/client/jvm.dll<br />if exist "%PR_JVM%" goto foundJvm<br />rem Check for JRockit JVM: Bugzilla 39674<br />set PR_JVM=%JAVA_HOME%/jre/bin/jrockit/jvm.dll<br />if exist "%PR_JVM%" goto foundJvm<br />set PR_JVM=auto</p><p>:foundJvm<br />echo Using JVM: %PR_JVM%<br />"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop<br />if not errorlevel 1 goto installed<br />echo Failed installing '%SERVICE_NAME%' service<br />goto end<br />:installed<br />rem Clear the environment variables. They are not needed any more.<br />set PR_DISPLAYNAME=<br />set PR_DESCRIPTION=<br />set PR_INSTALL=<br />set PR_LOGPATH=<br />set PR_CLASSPATH=<br />set PR_JVM=<br />rem Set extra parameters<br />"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%/common/endorsed" --StartMode jvm --StopMode jvm<br />rem More extra parameters<br />set PR_LOGPATH=%CATALINA_BASE%/logs<br />set PR_STDOUTPUT=auto<br />set PR_STDERROR=auto<br />"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%/temp" --JvmMs 128 --JvmMx 256<br />echo The service '%SERVICE_NAME%' has been installed.</p><p>:end<br />cd %CURRENT_DIR%<br />

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.