How to run Apache Tomcat as a Windows Service with FireDaemon ProHow to run Apache Tomcat as a Windows Service with FireDaemon Pro


Apache Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies.


Apache Tomcat can be run as a Windows service using FireDaemon Pro. This allows you to start and run the application automatically when Windows boots and before login. FireDaemon Pro also allows you to start multiple instances of the server, monitoring them and automatically restarting those instances in the event they crash. FireDaemon Fusion can also be used to manage your Apache Tomcat service, plus other Windows services via your web browser.


Apache Tomcat Setup Under FireDaemon Pro

Please follow the steps below to set up an Apache Tomcat as a Windows service with FireDaemon Pro


Step 1: Download and Install Java

Java 8 is supported until 2030 so we recommended you use this version. Oracle changed their download policy for Java and to download it, you need to make a free Oracle account and login. There are 2 types of java you can install:

  1. Java Server (JRE): This has performance optimizations and you can download the latest Java 8 Windows x64 Server JRE from the java website at the bottom of the page. Extract the contents of the zip to your hard drive, for the purposes of this guide we will use "C:\jdk1.8.0_271". The folder name will be different if you're using a different Java version. This guide assumes you're using this version.
  2. Java SE: This has performance optimizations and you can download the latest Java 8 Windows x64 Jave SE from the java website at the bottom of the page. Extract the contents of the zip to your hard drive, if you use this version extract to "C:\jre1.8.0_271". The folder name will be different if you're using a different Java version.

Step 2: Download and Install Apache Tomcat

  1. Download from here. Make sure you get the latest (stable) binary zip release.
  2. Extract the zip someplace on your hard drive. For the purposes of this guide we will use: "C:\apache-tomcat-9.0.39". The folder name will be different if you're using a different version.


Step 3: Set Up Apache Tomcat as a FireDaemon Pro Service

Download and install FireDaemon Pro. Double click the FireDaemon Pro icon on your desktop, then click on the New (i.e. +) button in the toolbar (or type Ctrl + N) to create a new service. Enter the information into the fields as you see below. Adjust the path names to suit your installation. Note the required parameters.


Apache Tomcat Dedicated Server Service Program Tab: Run as Windows Service


The most important field on the tab is the Parameters. The Parameters define the initial setup of your server. The full parameter list should be as follows:

-Djava.util.logging.config.file="%LOG_CONFIG%" -Djava.util.logging.manager=%LOG_MANAGER%  -Djdk.tls.ephemeralDHKeySize=%KEY_SIZE% -Djava.protocol.handler.pkgs=%PROTOCOL_HANDLER%   -Dignore.endorsed.dirs="%ENDORSED_DIRS%" -classpath "%CLASS_PATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMP%" org.apache.catalina.startup.Bootstrap start

The above commands need to be added in their entirety. They allow Tomcat to run as a service.


Step 4: Next, click on the FireDaemon Pro Settings tab:


Apache Tomcat service settings: Run as Windows Service


Enter appropriate values in the fields on the Settings tab as follows:

  • (Required) Job Type: You must set job type to "Global Job".
  • (Required) Logon Account: Enter the Windows account under which the application is to be run, e.g. the current administrator account.
  • Password / Confirm Password:  Enter the logon account's password twice.
  • (Optional) Interact with Desktop: If this setting is enabled (default), the application's output messages can be seen in the console window on Windows Session 0. To switch to Session 0, it may be necessary to install FireDaemon Zero and ZeroInput. Alternatively, this setting may be disabled, in which case the application's messages will be hidden.
  • (Optional) Priority: To allocate more CPU time to the application, select a higher scheduling priority in this field.
  • (Optional) CPU Bindings: To run the application on a specific CPU, specify the appropriate CPU in this field.


Step 5: Next, click on the Lifecycle tab. 

Set Shutdown By to Forceful Termination and check "Console Program".


Apache Tomcat lifecycle settings: Run as Windows Service


Step 6: Now click on the Environment tab. 

This is where you enter environment variables specific to your Tomcat instance. The names and values of the environment variables are below; adjust your paths to suit your installation. Adjust the paths below to the version of Tomcat you have installed. Note that environment variable order is important:


Service Definition: Run as Windows Service

TOMCAT_JAVA_HOME: C:\jre1.8.0_271
LOG_CONFIG: C:\apache-tomcat-9.0.39\conf\logging.properties
LOG_MANAGER: org.apache.juli.ClassLoaderLogManager
KEY_SIZE: 2048
PROTOCOL_HANDLER: org.apache.catalina.webresources
ENDORSED_DIRS
CLASS_PATH: C:\apache-tomcat-9.0.39\bin\bootstrap.jar;C:\apache-tomcat-9.0.39\bin\tomcat-juli.jar
CATALINA_BASE: C:\apache-tomcat-9.0.39
CATALINA_HOME: C:\apache-tomcat-9.0.39
CATALINA_TMP: C:\apache-tomcat-9.0.39\temp

Step 7: Lastly, click the Save and Close (ie. the tick) button on the toolbar. 

If the service's Startup Type is set to Automatic or Automatic (Delayed-Start), it will start immediately.


FireDaemon Pro Services list: Run as Windows Service


If the service's Interact with Desktop setting is enabled, the Apache Tomcat status can also be verified by switching to Windows Session 0 to view the Apache Tomcat's messages.


Apache Tomcat messages window: Run as Windows Service

Point your browser at the Tomcat instance to ensure it is up and running. If you have issues, refer to the FireDaemon debug log file, Windows Event Viewer and the Tomcat log files. Alternately, run the FireDaemon service interactively and turn off logging to Stderr/Stdout so you can see what is happening when the Tomcat instance starts.


Apache Tomcat Local Instance Webpage: Run as Windows Service


**********************************************************************************
How to run Apache Tomcat as a Windows service for 24x7 availability
How to monitor and restart Apache Tomcat if it crashes, hangs or shuts down
How to start Apache Tomcat at system boot, without any user intervention
How to schedule Apache Tomcat to start/restart at specific times and dates
**********************************************************************************