Introduction
Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation. It is used to deploy Java-based web applications and provides a Java HTTP web server environment for Java code to run in. Installing Apache Tomcat on Windows is a straightforward process and can be completed in a few steps. This guide will walk you through the process of installing Apache Tomcat on Windows.
How to Install Apache Tomcat on Windows
1. Download the latest version of Apache Tomcat from the Apache Tomcat website.
2. Extract the downloaded file to a folder of your choice.
3. Open the folder and double-click the “setup.exe” file to start the installation process.
4. Follow the on-screen instructions to complete the installation.
5. Once the installation is complete, open the “bin” folder in the Tomcat installation directory.
6. Double-click the “startup.bat” file to start the Tomcat server.
7. Open a web browser and type “localhost:8080” in the address bar.
8. You should see the Tomcat welcome page, which indicates that the installation was successful.
Introduction
Apache Tomcat is an open-source web server and servlet container for Java code. Tomcat executes programs written in the Java programming language, and it implements many Java EE specifications, including Jakarta Servlet, Jakarta Server Pages, and others.
In this tutorial, you will learn to install the Apache Tomcat server on Windows.
Prerequisites:
How to Install Tomcat on Windows
In this section, we will cover two ways of installing the Tomcat web server:
- Via Windows Service Installer.
- From a zip archive.
Follow the steps below to download and install Tomcat.
Step 1: Download Tomcat for Windows
To download the Tomcat installation file, follow the steps below:
1. Browse to the official Apache Tomcat website. Locate the Download section and click the latest Tomcat version available. At the time of writing this article, the latest Tomcat version was version 10.
2. On the Download page, scroll down and locate the Binary Distributions area.
In the Core list, depending on the installation type you prefer, click the download link for the Windows Service Installer or the 32bit/64bit Windows zip file.
Step 2: Install Tomcat
Install Tomcat via the Windows Service Installer for an automated and wizard-guided experience. The service installer installs the Tomcat service and runs it automatically when the system boots.
For a portable experience, install Tomcat using the zip file and avoid installing the service. Easily uninstall Tomcat when it is no longer needed by deleting the Tomcat directory, or move it around when necessary.
Note: Take a look at our list of 13 best Java IDEs, which help write, debug, and test Java code.
Method 1: Install Tomcat Using the Windows Service Installer
Follow the steps below to install Tomcat using the Windows Service Installer.
1. Open the downloaded Windows Service Installer file to start the installation process.
2. In the Tomcat Setup welcome screen, click Next to proceed.
3. Read the License Agreement and if you agree to the terms, click I Agree to proceed to the next step.
4. In the Tomcat component selection screen, choose Full in the dropdown menu to ensure the wizard installs the Tomcat Host Manager and Servlet and JSP examples web applications. Alternatively, keep the default Normal installation type and click Next.
5. The next step configures the Tomcat server. For instance, enter the Administrator login credentials or choose a different connection port. When finished, click Next to proceed to the next step.
6. The next step requires you to enter the full path to the JRE directory on your system. The wizard auto-completes this if you have previously set up the Java environment variables. Click Next to proceed to the next step.
7. Choose the Tomcat server install location or keep the default one and click Install.
8. Check the Run Apache Tomcat box to start the service after the installation finishes. Optionally, check the Show Readme box to see the Readme file. To complete the installation, click Finish.
9. A popup window appears that starts the Tomcat service. After the process completes, the window closes automatically. The Apache Tomcat web server is now successfully installed .
Method 2: Install Tomcat Using the zip Archive
Follow the steps below to set up the Tomcat server using the zip archive.
1. After downloading the 32bit/64bit Windows zip file, depending on your Windows version, unzip the downloaded file. Right-click the file and select Extract all…
2. Choose where to extract the archive contents. For easier navigation, we recommend extracting it to the hard drive’s root. Optionally, give the directory a shorter name to facilitate server configuration later. Click Extract to start the process.
3. Navigate to the conf sub-directory within the extracted directory and locate the server.xml file.
Important: Back up the .xml files before making any changes.
4. The default connection port is 8080
. To choose a different port, edit the server.xml file with a text editor, such as Notepad++, and locate the following lines:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Change the connector port
number to any number between 1024
and 65535
.
5. To enable directory browsing, locate the web.xml file in the conf directory and edit the file with a text editor. Directory browsing helps when testing the system, and sometimes it may be the solution for a 403 forbidden error.
Locate the following lines and change the listings
value from false
to true
:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
6. Implement an auto-reload feature by editing the context.xml file. Above all, auto-reload is useful in development to prevent restarting the server manually each time a change is made.
Using a text editor, open the context.xml file. Locate the following line and change the value from false
to true
in each instance:
<Context reloadable="false" crossContext="false" parallelAnnotationScanning="false">
......
......
</Context>
7. After making the changes, start the server. Press the Windows key and type cmd. Press Enter to open a Command Prompt window.
8. Move to the bin directory of your Tomcat server and run:
startup
8. Add an exception for Tomcat in the firewall:
9. A new Tomcat console window appears. This console receives error messages and system.out.println()
messages issued by the Java servlets.
10. Access the server using a browser as an HTTP client. Browse to http://localhost:8080 and access the Tomcat welcome page to ensure the server works.
In addition, use the Developer Quick Start links to see more information about the server and start using and configuring the server.
11. Shut down the Tomcat server by pressing Ctrl+C on the Tomcat console.
Step 3: Check if Apache Tomcat Service Is Running
Installing Tomcat using the Windows Service Installer installs Tomcat as a Windows service that automatically runs on boot. Follow the steps below to ensure that Tomcat is started as a Windows service.
1. Open the Start menu and search for Services.
2. Select the Services result.
3. In the Services window, locate the Apache Tomcat service. The Status column indicates whether the service is running or not. Start or Stop the service using the buttons in the toolbar or by pressing Stop or Restart on the left side of the service list.
Configure the service startup by right-clicking the Tomcat service and selecting Properties.
4. In the Properties window, under the Startup type dropdown menu, select how to run the Tomcat service:
- Automatic (Delayed Start). Starts the service shortly after boot. A delayed start improves server boot performance and has security benefits.
- Automatic. Automatically starts the service on boot.
- Manual. The service starts only when Windows or another service needs it or if invoked.
- Disabled. Disables the service startup, even if you try to start it.
Click OK to confirm the changes.
Note: If you are looking for a different operating system, our Knowledge Base also has a tutorial on how to install Tomcat on Ubuntu.
Conclusion
This guide showed how to install the Apache Tomcat web server on Windows. While Tomcat doesn’t provide all the features of Java EE, many applications require only the features that Tomcat provides. Therefore, heavier tools aren’t always necessary.
Learn more about servers in our tutorial on big data servers, or learn what a database server is.
How to Install Apache Tomcat on Windows
Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation. It is used to deploy Java Servlets and JSPs (JavaServer Pages). This tutorial will guide you through the process of installing Apache Tomcat on a Windows machine.
Prerequisites
- A Windows machine
- Java Development Kit (JDK) installed
Step 1: Download Apache Tomcat
The first step is to download the latest version of Apache Tomcat from the official website. You can find the download link here. Once the download is complete, extract the zip file to a folder of your choice.
Step 2: Set Environment Variables
The next step is to set the environment variables. This will allow the Windows machine to recognize the Tomcat installation. To do this, open the Control Panel and go to System and Security > System > Advanced system settings. In the Advanced tab, click on Environment Variables. In the System Variables section, click on New. Enter the following information:
- Variable name: CATALINA_HOME
- Variable value: The path to the Tomcat installation folder
Click OK to save the changes.
Step 3: Start the Tomcat Server
Now that the environment variables are set, you can start the Tomcat server. To do this, open a command prompt and navigate to the bin folder of the Tomcat installation. Then, type the following command:
catalina start
This will start the Tomcat server. You can verify that the server is running by opening a web browser and navigating to http://localhost:8080. If the server is running, you should see the Tomcat welcome page.
Step 4: Stop the Tomcat Server
When you are done using the Tomcat server, you can stop it by typing the following command in the command prompt:
catalina stop
This will stop the Tomcat server.
Conclusion
In this tutorial, you learned how to install Apache Tomcat on a Windows machine. You also learned how to set the environment variables and start and stop the Tomcat server. With this knowledge, you can now deploy Java applications on your Windows machine.