11.2. Starting Tomcat

Problem

You want to get Tomcat running.

Solution

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

Discussion

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

JAVA_HOME

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.

CATALINA_HOME

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 startup.sh 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 shutdown.sh 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 ...

Get Eclipse Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.