Message-ID: <18970167.459.1711630073809.JavaMail.serveradmin@t01app> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_458_6648280.1711630073801" ------=_Part_458_6648280.1711630073801 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html 5.0 Zero Footprint Tomcat 6.x & Instances on Windows

5.0 Zero Footprint Tomcat 6.x & Instances on Windows

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 mu= ltiple instances.

You trade the capability of multiple instances for not being able to hav= ing the "windows installer" setup the gui system tray, but that's not a nec= essary 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<= /a>.

Manually Setup Tomcat

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

The first step is to download the zip version of Tomcat for Wind= ows.

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

Running Tomcat with a specific JRE version

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

=20
SET JRE=
_HOME=3DC:\opt\tomcat.0\java
=20

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..

SET JRE_HOME=3D%CATALINA_HOME%\java

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

=20
version=
.bat
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:  6.0.26.0
OS Name:        Windows 2003
OS Version:     5.2
Architecture:   x86
JVM Version:    1.6.0_20-b02
JVM Vendor:     Sun Microsystems Inc.
=20

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

Automatic Startup and Shutdown of Tomcat

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

=20
cd C:\o=
pt\tomcat.0\bin
service.bat install tomcat.0
=20

If successful you will see the following,

=20
Install=
ing 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.
=20

I have proven and working used, service.bat install tomcat0 but never with the period. The period may not work. S= omebody 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 s= ervice.

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

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

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

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 se= rvice, 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 mig= ht work. Try this out on a test machine sometime. Also, I just confirmed th= at not setting JavaHome or any kind of Java works fine with the service. Wi= ndows 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 particular= s to your particular instance of Tomcat,

=20
Windows=
 Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"ApacheTomcatMonitora"=3D"\"C:\\opt\\tomcat.0\\bin\\tomcat6w.exe\" //MS//To=
mcat Instance tomcat.0"
=20

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

Put the file on the server and double-click the file. You will be prompt= ed with a warning dialog as this is modifying the windows registry and prov= ided 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 p= articular instance in your system tray.

The registry entry equates to automatically running the following comman= d upon login,

=20
tomcat6=
w.exe "//MS//Tomcat Instance tomcat.0"
=20

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

Setup Tomcat Instance 1

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

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

=20


Next, repeat Automatic Startup and Shutdown of Tomcat a= nd Tomcat Icon on System Tray with adjustment for the diff= erent name and directory.

R= eferences

http://tomcat.apac= he.org/tomcat-6.0-doc/windows-service-howto.html#Tomcat6w - Background = on how to add to system try.

------=_Part_458_6648280.1711630073801--