Step-by-step guide for installing tomcat on windows

Tomcat is an open source java application server provided by Apache, it is the most popular application server for java environment. In this article we provide a step-by-step guide for installing and setting up tomcat in windows environment,  for those who are interested in unix machines you can refer to this guide.

1. Prerequisite

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

Follow this tutorial to setup java on your windows machine.

 2. Installation

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.

Tomcat as a windows service:

The main benefit for 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 to keep the default configuration as it is, you can always change these 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.

Tomcat as a standalone application:

If you want to manage manually the startup of tomcat, 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 “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. Configuration

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

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

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.

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

 

Hussein Terek

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

You may also like...

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
1 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
husseinterekUmesh Recent comment authors
newest oldest most voted
Umesh
Guest
Umesh

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