February 8, 2012

Tomcat Server running as a Windows Service

How to install service for Tomcat to start automatically after reboot on Windows. These are instructions for adding Windows Service when Tomcat is run from archive installation.
3 min read · 468 words

Following instructions were based on Tomcat 6 and are now updated for Tomcat 9. The specifics are compatible with all Tomcat from version 6.

1. Prerequisite

Assuming you already have extracted Tomcat, navigate to bin folder of your Tomcat installation. The folder should contain three files: service.bat, tomcat9.exe and tomcat9w.exe. If you are using other Tomcat version than these files might be tomcatX.exe and tomcatXw.exe where ‘X’ is Tomcat major version number.

If these files are not there, then you have to manually add them, otherwise skip to the next step.

1.1 Adding service management files

First, figure out which version of Tomcat you have and figure out architecture (x86 or x64). Next, go to one of Tomcat download pages and download Windows Service Installer.

For newer versions of Tomcat find appropriate download page on official Tomcat website. Extract downloaded archive and navigate to bin folder and copy service.bat, tomcatX.exe  and tomcatXw.exe to your Tomcat installation.

1.2 Install Windows Service

Firstly, stop Tomcat Server if is running. Then open CMD or Powershell window (with Administrator privileges) and navigate to Tomcat’s bin directory where you should have all three files. Execute following command:

service.bat install

Command output for Tomcat 9:

Installing the service 'Tomcat9' ...
Using CATALINA_HOME:    "C:\apache-tomcat-9.0.19"
Using CATALINA_BASE:    "C:\apache-tomcat-9.0.19"
Using JAVA_HOME:        "C:\Program Files\Java\jdk1.8.0_201"
Using JRE_HOME:         "C:\Program Files\Java\jdk1.8.0_201\jre"
Using JVM:              "C:\Program Files\Java\jdk1.8.0_201\jre\bin\server\jvm.dll"
The service 'Tomcat9' has been installed.

If command has executed successfully, a new service should be visible under Windows Services with name Apache Tomcat 9.0 Tomcat9.

1.3 Configure Windows Service

Following instruction are based on Tomcat official guide available at

From CMD or Powershell run following command:

tomcat9w.exe //ES//

//ES// is the default operation. It is called if the no option is provided but the executable is renamed to servicenameW.exe

A new Tomcat Windows Service Configuration windows should be visible. Here you can configure service name, description, startup type, JVM settings, etc. At least what you want to do is to set startup type to Automatic and increase Maximum Memory Pool under Java tab.

For Java versions prior to Java 8, add a new line -XX:MaxPermSize=256m under Java Options section. This will increase Java heap size. You sure want to modify value for your needs. This setting is very important as running Tomcat as service will override all other settings from default Tomcat except to this.

Now you can start Tomcat as a service. Run (Windows + R) services.msc or access it from the Tak Manager (Services tab).

This way you can automatically start Tomcat Server on Windows start.

1.4 Remove Windows Service

Open CMD or Powershell window and navigate to Tomcat’s bin directory. Run following commmand:

service.bat uninstall

Output for Tomcat 9.x:

Removing the service 'Tomcat9' ...
Using CATALINA_BASE:    "C:\apache-tomcat-9.0.19"
The service 'Tomcat9' has been removed