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%
保存文件。