The Tomcat Service for Windows - A Simple Guide
Running Tomcat as a Windows Service provides a number of benefits that are essential when moving from a development set-up to a production environment.
- Reliable automatic startup on boot - essential in an environment where you may want to remotely reboot a system after maintenance without worrying about whether your server will come back online.
- Server startup without active user login - in a data center, it is not reasonable to expect an active login from the system just to run Tomcat. In fact, Tomcat is often run on blade servers that may not even have an active monitor connected to them. Windows Services are owned by the System, and can be started without an active user.
- Security - If you run Tomcat as an administrator, a vulnerability in one of your web applications can open up your whole server to attack. Running Tomcat as a Windows Service allows you to run it under a special system account, which is isolated and protected from rest of the user accounts.
Now that you know the benefits, you probably want to know how you can get the Tomcat Windows Service up and running.
Look no further: here's a simple, comprehensive look at the Tomcat Windows Service, from installation and configuration, to fine-tuning and debugging.
The latest version of Tcat makes installing multiple Tomcat instances as Windows Services easier than ever. Download Tcat and try for yourself!
Installing Tomcat as a Windows Service
Tomcat's Windows service is included with all the actively supported Windows-specific distributions of Tomcat, including a lightweight package aimed at users who intend to use Tomcat exclusively as a Windows service, which does not include the standard Tomcat start-up scripts.
Installing Tomcat as a service is very easy. In fact, if you used the Windows installer program to install Tomcat on your system, Tomcat has already been installed as a service automatically.
If you didn't use the installer, the quickest way to install Tomcat as a service is to run the "service.bat" batch script from Tomcat's bin folder, which will install and configure the service for you.
If you want to get picky about parameters or the name of the service, you can run tomcat6.exe from the command line with the /IS/ parameter:
C:\> tomcat6 /IS/Tomcat6 --DisplayName="Pick A Name" \
C:\> --Install="C:\Path\To\bin\tomcat6.exe \
Note that when using this method, you will have to use Tomcat6.exe's command line parameters to specify things like the class that should be used to start and stop Tomcat. Any configuration options that you do not set during the initial /IS/ parameter call must be configured using the /US/ parameter. An overview of parameters and switches for use with Tomcat6.exe is provided later in this article.
Starting the Tomcat Windows Service Automatically
Now that you have installed Tomcat as a service, you can configure it to start automatically using the Windows Services configuration pane, a tab of the Control Panel's Administrative Tools pane. As of Windows Vista, you can choose from four start-up options for any windows service. To start the Tomcat service automatically at logon, set the startup type to either "Automatic", which will trigger Tomcat start immediately on login, or "Automatic (Delayed)", which will delay startup slightly to allow a faster system boot.
Tomcat's Service Applications
Tomcat includes two service-related Windows applications, named Tomcat6.exe and Tomcat6w.exe (if you are running an older version of Tomcat, the names of these programs will reflect this, e.g. Tomcat5.exe and Tomcat5w.exe). These programs are located in Tomcat's /bin/ directory.
Tomcat6 is the actual service wrapper program that allows Tomcat to be run as a service, and will run entirely in the background after it has been installed, and accepts a long list of command line parameters that allow precise configuration of the Tomcat service. A guide to these parameters is provided later in this article.
Tomcat6w is a simple graphical tool that can be used for monitoring and configuring the service after it has been installed, and can also appear in the system tray for quick access. You can also use this tool to set many of Tomcat6's command-line parameters, although this is done by manually typing the parameters into the window, not through a graphical interface. This tool can also be used to manually start and stop the Tomcat service if desired.
Command-Line Parameters for Tomcat6.exe
Here is an overview of the command line parameters available for use with Tomcat6.exe. The default syntax for all these commands is:
If you configured a custom service name when you installed the service, use this in place of "Tomcat6" in the command.
- /IS/ - Install service. Used during the initial installation only.
- /US/ - Update service. Used to change service parameters after installation.
- /SS/ - Stop Service. Stops the Tomcat Windows Service, if running.
- /RS/ - Run Service. Manually start the Tomcat service from the command line.
- /TS/ - Terminal Service. Runs the service as a console application. Tomcat6 runs this command by default if no other parameter is specified. This command can be used in conjunction with other parameters to provide debug functionality for the Tomcat service.
- /DS/ - Delete Service - Stops the service if it is running, and then deletes it.
There is a very long list of command line parameters that are used in conjunction with these commands to define additional command parameters. In the interest of simplicity, this list is not included in this article.
For comprehensive information about Tomcat6.exe command-line parameters, please visit the Apache Tomcat project site.