How to install Apache Tomcat on Windows

Tomcat is an open-source Java application server provided by Apache, it is the most popular application server for the java environment. In this article, we provide a step-by-step guide on how to install and set up an apache tomcat in a windows environment.

1. Prerequisites

Tomcat doesn’t work without Java, so before installing tomcat on the machine, you should install a compatible Java runtime version and set up the JAVA_HOME environment variable. Both java and tomcat versions should be compatible so I recommend always install the same version for java and tomcat, in this tutorial we use java 8 and tomcat 8.

 2. Installation Steps

There are two ways for installing tomcat in a windows machine, you can either install it as a windows service or as a standalone application.

2.1 Install Tomcat as a windows service

The main benefit of installing Tomcat as a windows service is to allow starting it automatically at the startup of the windows.

Following are the steps for installing and setting up tomcat as a windows service:

  1. Download the windows service installer from here.Download Tomcat 8
  2. Install the downloaded file, pass all the setup until reaching Configuration OptionsTomcat 8 configurationhere you can set the service name, the shutdown port, and the running port of tomcat, by default tomcat runs on port 8080,  so I recommend keeping the default configuration as it is, you can always change this configuration after the installation.
  3. After completing the installation, the tomcat folder can be found under “C:\Program Files\Apache Software Foundation\Tomcat 8.5”.
  4. If you open the windows services, you find a new service called Apache Tomcat 8.5 Tomcat8, change its startup type to Automatic.

And here you go, tomcat is installed as a windows service, and will start at the windows startup.

2.2 Install Tomcat as a standalone application:

If you want to manage the startup of tomcat manually, you can install it as a standalone application through the following steps:

  1. Download the tomcat zip file from here.Download Tomcat 8
  2. Extract the downloaded zip under the “D:” drive.
  3. To start tomcat, run startup.bat” file under “D:\apache-tomcat-7.0.35\bin”.
  4. To stop tomcat, run shutdown.bat” file under “D:\apache-tomcat-7.0.35\bin”.

 3. Change the default port of Tomcat

To change the default running port of tomcat, open server.xml” under the “D:\apache-tomcat-7.0.35\conf” folder and change the port attribute of the Connector tag.

Here, we set tomcat to run on port 9095, a restart is required for the change to take effect.

4. Check if Tomcat is up

In order to make sure that tomcat is started up correctly on the configured port, just run localhost:9095 URL on any browser and if you get the following screen then tomcat is up and ready to serve requests.

Tomcat 8 runs successfully

 4. Tomcat Logging

Tomcat log files can be found under “D:\apache-tomcat-7.0.35\logs”, there are 2 important log files to be checked when investigating applications issues:

  • tomcat8-stderr.<date>.log: This file logs all the runtime exceptions which are thrown by the running application.
  • tomcat8-stdout.<date>.logThis file displays all the trace and info logs generated by the application.

If these files are not found, you can check the catalina.<date>.log file which holds all the exceptions and info logs generated by the application.

 

0 0 votes
Article Rating

Hussein Terek

Founder of programmergate.com, I have a passion in software engineering and everything related to java environment.

guest
6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Umesh
Umesh
3 years ago

Well explained sir. Specially great way of writing your contents. Really this is impressive.
Thanks a lot.
Programmer Mart

Nath
Nath
2 years ago

Excellent Bog.

Pakul Raxan
Pakul Raxan
1 year ago
Reply to  Nath

very bog, indeed.

Adefemi Kolawole
Adefemi Kolawole
1 year ago

Great and simple explanation. As a developer intern, I was able to get the tomcat server running in minutes. Thanks

zap3001
zap3001
1 year ago

If using the installer for Tomcat 7, 8 or 9, the installation switches for /C=config.ini and /D=INSTDIR do not seem to work or not clear how to specify or even using the config.ini and including JavaaHome= and TomcatPortHttp= in the config.ini does not seem to work. I wish there was more info on that.