How to install Tomcat in Windows?

Installing Apache Tomcat in Windows
The following gallery and steps provide complete guide on how to install and configure tomcat in Windows so that you can work with Servlets and JSP. Here is a step by step instruction with images on how to install tomcat and run the servlet programs.





1. Download the Apache Tomcat 7

I personally use the latest version of Tomcat so I recommend it. Download the .exe file (for Windows) of Apache Tomcat 7. In this page you will find Binary Distributions and under it you'll find Windows Service Installer click on it and the file will be downloaded.

2. Installing the Tomcat

Here is a photo gallery of each screenshot on how to install tomcat right from the starting. Follow the instructions.

Welcome to Tomcat Installation
Welcome to Tomcat. Click Next


Apache Tomcat License Agreement. Click on Agree
Accept license agreement
Type of installation of Tomcat. Choose FULL.
Choose FULL installation, click NEXT
Tomcat Configuration. Click NEXT
Selecting Tomcat JVM Path. Click NEXT
Tomcat JVM path Selection. Click NEXT
Choose Tomcat Installation Directory. Default is recommended. Click NEXT.
Tomcat Installation DIR. Click NEXT
Tomcat is Installing. Do nothing.
Installing TOMCAT..
Finish TOMCAT installation. Click FINISH.

3. Installed Properly?

To check if Tomcat is installed properly try opening the Tomcat page in your web browser. It is very simple. In the images above i mentioned you to note the port number. It is very important to run your servlet applications. For me i installed in 8080 so I will open, http://localhost:8080 in my web browser. Then I'll see the following page.


Tomcat Homepage, a symbol of successful Tomcat installation

3.1 Still... Do the servlets work?

It works actually. OK, if you doubt let's check it simply by executing a Hello world servlet program.


Click on Servlets Examples
Click on Servlets Examples..

Executing Hello World in Servlets
Execute Hello World

Now it's my time. I'll have to code!

OK. Good. But before you do the application, set the classpath for the servlets to work with servlets, JSP (only if you work with JSP). It is very easy. Just copy the required jar file paths and then paste them one by one followed by a semicolon (;). That's it. See the image for a better understand.

If you want to work with servlets then you need servlet-api.jar
If you want to work with JSP you need jsp-api.jar
Both of the jar  files are located in the Tomcat lib directory. Just take a look at them.

Note the required JAR files for Servlets present in Tomcat lib folder
Add the required jar files. Note them first.

Now set the classpath.


Go to Advanced and Click on Environment Variables

Click on NEW either in USER variables/system variables

Set the path of those jar files and click OK

Click on all the OK's that you see. The command prompt that is previously opened will not be able to detect the modified classpath, you'll need to open a new command prompt to see it working. If any problem persists feel free to drop a comment.

In this way we can simply install Apache Tomcat in a Windows PC. Hope this guide has helped a lot. Thanks for reading this post with utmost patience.

No comments: