tomcat开机启动服务

安装好tomcat6后,在bin目录有这三个文件 tomcat6w.exe、tomcat6.exe、startup.bat 他们都与启动tomcat有关。

tomcat6.exe这个文件是用来启动tomcat的 ,双击它出现个DOS样子的窗口一闪而过消失了,tomcat也没有启动成功。双击tomcat6w.exe弹出个错误对话框,说“指定的服务并未以安装的服务存在。Unable to open the service tomcat6”。其实这两个文件要起作用,必须先为这个tomcat开通服务。

tomcat开通服务:

1编辑service.bat文件。

rem Guess CATALINA_HOME if notdefined
set CURRENT_DIR=%cd%
##添加下面一句指定tomcat的安装目录(%TOMCAT_PATH%为tomcat安装的绝对路径)。
     set CATALINA_HOME=%TOMCAT_PATH%
     if not "%CATALINA_HOME%" == ""goto gotHome
     set CATALINA_HOME=%cd%

##为了在“进程”中跟其他安装的tomcat区分名字,修改tomcat6.exe 的文件名。这里假设修改成tomcat6018.exe。

if exist"%CATALINA_HOME%\bin\tomcat6018.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat6018.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end 
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase
 
set EXECUTABLE=%CATALINA_HOME%\bin\tomcat6018.exe

rem Set default Service name

##创建服务后的服务名称,这个名称必须唯一。
set SERVICE_NAME=Tomcat6018

##创建服务后的服务显示名称,这个名称可以与其他服务显示名称相同。
set PR_DISPLAYNAME=Apache Tomcat 6018
............ (中间省略)
"%EXECUTABLE%"//US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"--JvmMs 128 --JvmMx 256

如果你需要把服务设置为开机自启动,可以加上下面这句(位置为文件倒数第三行前面)

sc config %SERVICE_NAME% start=auto
echo The service'%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

保存文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值