安装好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 okHomerem CD to the upper dircd ..set CATALINA_HOME=%cd%:gotHomeif exist "%CATALINA_HOME%\bin\tomcat6018.exe" goto okHomeecho 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 programgoto endrem Make sure prerequisite environment variables are setif not "%JAVA_HOME%" == "" goto okHomeecho The JAVA_HOME environment variable is not definedecho This environment variable is needed to run this programgoto end :okHomeif not "%CATALINA_BASE%" == "" goto gotBaseset CATALINA_BASE=%CATALINA_HOME%:gotBase set EXECUTABLE=%CATALINA_HOME%\bin\tomcat6018.exerem 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=autoecho The service'%SERVICE_NAME%' has been installed.:endcd %CURRENT_DIR%保存文件。