Creating Tomcat6 Windows Services

Running the default Windows Tomcat installer a Tomcat server named Tomcat6 will be created on the Windows machine.

In the case the tomcat zipped installation file has been used, or if during the installation wizard the option for creating a Windows service hasn’t been checked, or finally, if it is required to have multiple Tomcat services running on the server, the Tomcat features to create new services should be used.

Obviously it’s required to have Java installed, in this case, it’s used the JDK.

The following batch script will install a tomcat service named YourTomcat related to a CATALINA_BASE located in c:\YourDir\YourTomcat.

set JAVA_HOME="c:\Program Files\Java\jdk1.6.0_12\"
set TOMCAT_HOME="c:\Program Files\Apache Software Foundation\Tomcat 6.0"
set CATALINA_BASE="c:\YourDir\YourTomcat"
call service.bat install YourTomcat

JAVA_HOME and TOMCAT_HOME are obviously the places where Tomcat and Java are installed.

What’s the CATALINA_BASE? In few words, from the same Tomcat installation (located in this example in c:\Program Files\Apache Software Foundation\Tomcat 6.0, the TOMCAT_HOME) it’s possible to run more than one server instances. Each Tomcat instance has its own deployed web applications, its own logs, its own configuration and so on.

The CATALINA_BASE needs to have those directories structure:

conf/
logs/
temp/
webapps/
work/

In conf/ it’s possible to copy the content of the conf/ directory of the Tomcat installation, and obviously these files have to be customized, depending on what is required for that specific Tomcat service, i.e. the HTTP, AJP and SHUTDOWN ports, and so on.

In logs/ each tomcat will write its custom Catalina logs or the web application specific logs (i.e. handled by Log4J).

In temp/ Tomcat will obviously place temporary files.

In webapps/ the web applications .war will be placed (and exploded).

in work/ the compiled .jsp will be placed.