Monday, September 26, 2011

Simple Batch Script to Run Tomcat

Sometimes it's a good idea to separate the actual Tomcat installation from the running configuration. Actually Tomcat comes with this ability built-in:
catalina.base
system property defines the location of the configuration, while
catalina.home
system property defines the location of the Tomcat installation.
And here comes the basic script that runs the Tomcat:

@echo off
setlocal

SET TOMCAT_BASE=c:\work\tomcats\tomcat1
SET TOMCAT_HOME=C:\tps\apache-tomcat-7.0.16
SET TOMCAT_CLASSPATH=%TOMCAT_HOME%\bin\bootstrap.jar;%TOMCAT_HOME%\bin\tomcat-juli.jar;%JAVA_HOME%\lib\tools.jar
SET JAVA_ENDORSED_DIRS=%TOMCAT_HOME%\endorsed
SET JAVA_OPTS=
SET JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.config.file="%TOMCAT_BASE%\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
SET JAVA_OPTS=%JAVA_OPTS% -Djava.io.tmpdir="%TOMCAT_BASE%\temp"
SET JAVA_OPTS=%JAVA_OPTS% -Dcatalina.base="%TOMCAT_BASE%" -Dcatalina.home="%TOMCAT_HOME%"
SET JAVA_OPTS=%JAVA_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%"

REM SET JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=n

%JAVA_HOME%\bin\java %JAVA_OPTS% -classpath %TOMCAT_CLASSPATH% org.apache.catalina.startup.Bootstrap start

endlocal

No comments: