Running TomcatS2C Home « Running Tomcat

In the previous lesson we downloaded, verified and installed the Tomcat server on our hard drives, but where is the server and how do we run it? In this lesson we will answer these questions as we look at starting up, testing and shutting down the Tomcat server gracefully. Before we do this lets have a look at the unzipped files. So double click on the folder where you extracted Tomcat to, which in our using Windows 7 example was the C:\apache-tomcat-7.0.41 directory. You should see files within the folder like the screenshot below:

tomcat directory

The files within the bin directory are what are of interest to us now, so double click on the bin folder and you should see files within the folder like the screenshot below:

tomcat bin directory

Setting A Classpath To The Java SDKgo to top of page Top

We need to point Tomcat to a java SDK and so we need to add a new environment variable called JAVA_HOME and a classpath entry. We downloaded a java SDK in the Java section of the site and in our case the SDK was installed to C:\Program Files\Java\jdk1.7.0_07\. Below is a screenshot of how this is achieved on my Windows 7 system and of course other OS will vary. But for Windows 7, from Control Panel, select System >> Advanced System Settings and at the bottom of the window select Environment Variables. Create a new system variable called JAVA_HOME and add C:\Program Files\Java\jdk1.7.0_07\ as the value (or whatever you selected as your filepath to the SDK).

environment settings

Once you have done this press OK on the windows to close them all.

Starting Up Tomcatgo to top of page Top

Ok with our new systen variable set up the first thing we need to do is open a command prompt and change the directory to the location of our Tomcat bin directory and then type in startup (Windows 7) or startup.sh (Linux/Unix/OSX). Press Enter and the Tomcat server should open up in a new window as shown by the following screenshot:

tomcat startup

Testing Tomcatgo to top of page Top

Now all we need to do to test our installation is running correctly is to go to a web browser and type in http://localhost:8080/ in the navigation bar and press enter. If all is well we should see the Tomcat welcome page as shown in the following screenshot:

tomcat welcome page

Shutting Down Tomcatgo to top of page Top

To shutdown our Tomcat server make sure you're in the bin directory and then type in shutdown (Windows 7) or shutdown.sh (Linux/Unix/OSX). Press Enter and the Tomcat server, and the server window opened on startup, will gracefully close as shown by the following screenshot:

tomcat shutdown

Lesson 2 Complete

That's it! We have started up, tested and shutdown Tomcat, which we can now use for testing our servlet 3.0 classes and JSP 2.2 pages.

go to home page Homepage go to top of page Top