Page tree
Skip to end of metadata
Go to start of metadata

This is a a companion article to 5.0 Zero Footprint Tomcat Instances on Ubuntu.

On Windows we can not make it totally portable and we can make use of multiple instances.

You trade the capability of multiple instances for not being able to having the "windows installer" setup the gui system tray, but that's not a necessary function.

Manually Setup JRE

The main advantage is here is there are no entries in your registry and no automatic updates of Java (which I find can cause problems).

I install the version of Java I want on a test machine such as a VM and then copy the uncompressed Java folder over to your server and rename it to C:\opt\apache\java.

For older of Java versions go to the Java Archives site.

Manually Setup Tomcat

Tomcat on Windows is also set up to run without requiring an installation. Some of this stuff is done by the Tomcat installer version, however, the installer can not handle multiple instances for vertical scaling. Investing the time in this article will allow you full control.

The first step is to download the zip version of Tomcat for Windows.

Unzip the folder to C:\opt. We will use the convention, C:\opt\apache\tomcat.0. The letter a designates an instance. As we scale up, you can have another instance called b, c and so forth.

Running Tomcat with a specific JRE version

Create a file called setenv.bat with the following contents using a plain text editor such as notepad,

SET JRE_HOME=C:\opt\tomcat.0\java

I've since found a more portable option using "$CATALINA_HOME" have only verified this works on my local Windows 7 machine. I still have to try this on a real server but it should work..


Verify your change using version.bat you will see the following results,

Using CATALINA_BASE:   "E:\opt\tomcat.0"
Using CATALINA_HOME:   "E:\opt\tomcat.0"
Using CATALINA_TMPDIR: "E:\opt\tomcat.0\temp"
Using JRE_HOME:        "E:\opt\java"
Using CLASSPATH:       "E:\opt\tomcat.0\bin\bootstrap.jar"
Server version: Apache Tomcat/6.0.26
Server built:   March 9 2010 1805
Server number:
OS Name:        Windows 2003
OS Version:     5.2
Architecture:   x86
JVM Version:    1.6.0_20-b02
JVM Vendor:     Sun Microsystems Inc.

That's it, Tomcat will actually run and start if you run it from the command line, however, Windows is not designed to run command line applications so see the next section.

Automatic Startup and Shutdown of Tomcat

In Windows, you probably want to make use of Windows Services to automatically startup, shutdown and even stop and start Tomcat.

cd C:\opt\tomcat.0\bin
service.bat install tomcat.0

If successful you will see the following,

Installing the service 'tomcat.0' ...
Using CATALINA_HOME:    "E:\opt\tomcat.0"
Using CATALINA_BASE:    "E:\opt\tomcat.0"
Using JAVA_HOME:        ""
Using JVM:              "auto"
The service 'tomcat.0' has been installed.

I have proven and working used, service.bat install tomcat0 but never with the period. The period may not work. Somebody validate for me.

We have now added Tomcat as a service to the windows registry. However, there is no reference yet to what version of java should be used with the service.

We will now issue commands to update the registry. If you want to see the updates in real time Start the registry,

  • Click Start, Run
  • Type, regedit and hit Enter to see the registry
  • Click Edit, Find
  • Search for tomcat.0

Now, we will update the registry to point to a specific version of Java.

cd C:\opt\tomcat.0\bin
tomcat6.exe //US//tomcat.0 --Jvm=C:\opt\java
tomcat6.exe //US//tomcat.0 --Jvm=C:\opt\java\bin\client\jvm.dll

Interestingly using JavaHome instead of jvm in the above commands seems to work too. Not sure of the difference.

Refer to the Tomcat Windows Service How-To if you need to configure more options.

Tin says, re-reading my notes here, I set the JavaHome in the Windows service, but with more thought, I think JavaHome is meant for a JDK. Why not set a JREHome? The Tomcat documentation does not show a JREHome, but it might work. Try this out on a test machine sometime. Also, I just confirmed that not setting JavaHome or any kind of Java works fine with the service. Windows might only need the --Jvm setting.

Tomcat Icon on System Tray

Finally, you can add Tomcat to the Windows System Tray.

First open notepad and put in the following text changing the particulars to your particular instance of Tomcat,

Windows Registry Editor Version 5.00

"ApacheTomcatMonitora"="\"C:\\opt\\tomcat.0\\bin\\tomcat6w.exe\" //MS//Tomcat Instance tomcat.0"

Save the file as tomcat.0-system-try.reg

Put the file on the server and double-click the file. You will be prompted with a warning dialog as this is modifying the windows registry and provided a success message once registry the entry has been added.

Log off and log on again. You should see the Tomcat Icon named to your particular instance in your system tray.

The registry entry equates to automatically running the following command upon login,

tomcat6w.exe "//MS//Tomcat Instance tomcat.0"

Finally log out and log back in. You should now see the tomcat icon on the system tray.

Setup Tomcat Instance 1

To set up another instance of Tomcat, I would call it tomcat.1, simply copy the tomcat.0 directory, change the ports as outlined in Ubuntu 5.0 Zero Footprint Tomcat 6.x & Instances. There is one difference in the Ubuntu steps and that is there is no grep command. Instead, provided you have Windows XP or higher you can use findstr,

netstat -an | findstr LISTEN | findstr 8105
netstat -an | findstr LISTEN | findstr 8109
netstat -an | findstr LISTEN | findstr 8180
netstat -an | findstr LISTEN | findstr 8543

Next, repeat Automatic Startup and Shutdown of Tomcat and Tomcat Icon on System Tray with adjustment for the different name and directory.

References - Background on how to add to system try.

  • No labels