Tomcat : Running multiple tomcat instances on Windows

This page last changed on Feb 02, 2009 by Kees de Kooter

Applies to Tomcat 6.0. The following procedure was tested on a Windows Server 2003 R2 box, but should work on all Windows NT based OS-es.

Copy instance specific files

I created a subdirectory instance under %CATALINA_HOME%. From a freshly installed Tomcat (using the Windows installer) I copied conf, logs, temp, webapps and work to a subdir named template.

Modify ports in server.xml

The port numbers for Service, Connector HTTP and Connector AJP have to be unique. I solved this by incrementing the second digit of every portnumber, i.e. 8180, 8280 etc.

Create the windows service

A windows service can be created by running tomcat6 with a myriad of command line options which are documented on the tomcat site. I put the essential ones in a script.

The script

Note that the tomcat6 command should all be on one line!


@echo off
rem Batch file for creating Windows services for tomcat instances.
rem Assumption: environment variable CATALINA_HOME is set
rem Author: Kees de Kooter
rem Date: 29-12-2008
rem Parameter: instance name (only alphanumeric characters: [A-Za-z0-9]*)
rem TODO: copy instance files first
rem copy %CATALINA_HOME%\instances\template %CATALINA_HOME%\instances\%1
rem TODO: make modifications to server.xml



rem Delete service if it already exists
tomcat6 //DS//%1

tomcat6 //IS//%1 \
--DisplayName="Tomcat 6 Instance %1" \
--Description="Tomcat 6 Instance %1" \
--Install="%CATALINA_HOME%\bin\tomcat6.exe" \
--Classpath="%CATALINA_HOME%\bin\bootstrap.jar" \
--Jvm=auto \
--Startup=auto \
--StartMode=jvm \
--StartPath="%CATALINA_HOME%" \
--StopMode=jvm \
--StartClass=org.apache.catalina.startup.Bootstrap \
--StartParams=start \
--StopClass=org.apache.catalina.startup.Bootstrap \
--StopParams=stop \
--StopPath="%CATALINA_HOME%" \
--Startup=auto \
--LogPath="%CATALINA_BASE%\logs" \
--StdOutput=auto \
--StdError=auto \

rem TODO: add memory settings

rem Copy service applet tomcat6w.exe to instance name
copy tomcat6w.exe %1w.exe /Y