Recipe 11.2 Starting Tomcat


11.2.1 Problem

You want to get Tomcat running.

11.2.2 Solution

Set the JAVA_HOME and CATALINA_HOME environment variables , change directories to Tomcat's bin directory, and type startup in Windows or run in Unix.

11.2.3 Discussion

Before starting Tomcat from the command line, you must set these two environment variables:


You set this environment variable to the installation directory of Java, the parent directory of the Java bin directory; e.g., C:\jdk1.4 in Windows or /usr/java in Unix.


You set this environment variable to the installation directory of Tomcat, the parent directory of the Tomcat bin directory; e.g., C:\tomcat\jakarta-tomcat-5.0.19 in Windows.

You can set these environment variables from the command prompt (in Windows that's the DOS prompt; in Unix it's the shell) as in this example:

 set JAVA_HOME=C:\jdk1.4 

How you do this varies by operating system; for example, in the Unix tcsh shell, use setenv instead. After setting these environment variables, run Tomcat by changing directories to Tomcat's bin directory and typing startup in Windows, or running in Unix. Note that in Windows, a new DOS window appears that displays initialization messages. To shut down Tomcat, type shutdown in Windows, or run in Unix at the command line.

Now that you've gotten Tomcat running, open a browser, and navigate to http://localhost:8080 , which should open Tomcat's Welcome page, as shown in Figure 11-1. The localhost part of this URL is what you use for web servers installed on your local machine (corresponding to an IP address of ), and 8080 is the port number (web servers usually use port 80, but Tomcat uses 8080 to avoid conflicts with other servers).

Figure 11-1. The Tomcat 5.0.19 startup page

When you store new .class files in the Tomcat directories or edit files such as the web.xml file you'll see later, you should stop Tomcat and restart it. Doing so makes sure Tomcat copies over your changes from its webapps directory to its work directory, which is what it actually serves documents from (there are ways to configure Tomcat so that you don't need to restart it this way, but that's beyond the scope of this book.

11.2.4 See Also

Recipe 11.1 on installing Tomcat; Chapter 1 in Tomcat: the Definitive Guide (O'Reilly); Chapter 4 in JavaServer Pages (O'Reilly); Chapter 9 in Eclipse (O'Reilly).

Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: