You are on page 1of 4

JDK/Tomcat Development Environment Setup

This setup guide covers the following setup steps:


a. Setting up the Java Development Kit (JDK);
b. Installing the Tomcat web server;
c. Configuring Tomcat to run as a Windows service;
d. Changing the delivered Tomcat TCP/IP port (8080);
e. Configuring the Tomcat manager application.

Installing the JDK

1. Create a directory on your C: drive called c:\java, and then a subdirectory called c:\java\setup.
The install instructions below assume that you’ve used this directory as your root—if you’d rather
use another location, feel free to change this, otherwise this is a good default choice (and future
documentation will assume it).

2. Download JDK 1.4.2_04 using the link below:

http://java.sun.com/j2se/1.4.2/download.html

Under the section labeled "Download J2SE v 1.4.2_04" (third section from the top—don’t pick the
J2EE or NetBeans installs) select the "32-bit/64-bit for Windows/Linux/Solaris" SDK link (not the
JRE). Accept the terms and conditions and click continue. On the following page, select "Windows
Offline Installation, Multi-language". Save j2sdk-1_4_2_04-windows-i586-p.exe to c:\java\setup.
The download will take a while--it is about 50 mb.

3. From c:\java\setup, double-click j2sdk-1_4_2_04-windows-i586-p.exe to start the install. Accept


the terms and conditions and click next.

We need to install "Development Tools", but the other three installs are not needed. Click on the
down arrow for "Demos", "Source Code" and "Public Java Runtime Environment", and for each
one, select "Don't install this feature now" to remove them from the installation.

Click on the Development Tools icon, then click the “Change” button to change the default install
location. Set the install directory to C:\java\j2sdk1.4.2_04\. Click ok, then click next. The install
will run to completion.

4. Add the JDK's "bin" directory to your Windows path. From the windows desktop, select Start->
Settings->Control Panel->System. Click the Advanced tab at the top. Click the "Environment
Variables" button. Find the system variable called path, and add c:\java\j2sdk1.4.2_04\bin to it.
For example, if your existing path was

%SystemRoot%\system32;%SystemRoot%;

you'd change it as follows:

c:\java\j2sdk1.4.2_04\bin;%SystemRoot%\system32;%SystemRoot%;

The 1.4.2_04 reference goes first in the list so it overrides any existing JDK versions. Click OK.

http://faculty.washington.edu/rfish/doc/java_tomcat_setup.pdf
5. Add an environment variable called JAVA_HOME. From the Environment Variables window, click
the lower New button to create a new variable. Call the variable JAVA_HOME, and set its value to
“c:\java\j2sdk1.4.2_04” (no quotes) . Click OK three times to close all the windows.

6. To ensure that the JDK is working properly, open a DOS window (Start->Run->cmd). Type the
command "java -version" and you should see the results below:

C:\Documents and Settings\rfish>java -version


java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

Type "exit" to close the DOS window.

Installing Tomcat

1. The easiest way to install Tomcat is to download a ZIPped version and unpack it into a directory.
To do this, download Tomcat 4.1.30 using the URL below:

http://www.apache.org/dist/jakarta/tomcat-4/v4.1.30/bin/jakarta-tomcat-4.1.30.zip

Save the file to c:\java\setup.

2. Unzip the Tomcat .zip file to c:\java. The zip file contains an embedded top-level directory
(Jakarta-tomcat-4.1.30), so when this step is completed, your c:\java directory should look like the
graphic below:

3. To test your Tomcat install, double-click on C:\java\jakarta-tomcat-4.1.30\bin\startup.bat. A


terminal window will open and some initialization statements will be logged to the window.

4. Once the logging stops, the URL below should produce the Tomcat default web page:

http://localhost:8080/index.jsp

5. If Step 4 doesn’t work, the problem is most likely with the JAVA_HOME environment variable.
Tomcat doesn’t require much in the way of system variables, but it wants this one set correctly.
Double-check the JDK install steps, and ensure that the JAVA_HOME variable is set as described.

6. To stop Tomcat, double-click C:\java\jakarta-tomcat-4.1.30\bin\shutdown.bat. After a few


seconds, the terminal window will close.

http://faculty.washington.edu/rfish/doc/java_tomcat_setup.pdf
Installing Tomcat as a Windows service:

Production web servers run 24x7, and for the Windows platform, application loading on server
startup is done using Windows services. The instructions assume you’ve installed to the default
installation location—you’re on your own if you’ve used a different directory structure (the service
installer will not work without modification).

1. Shut down Tomcat if it’s running.

2. Download JavaService.zip from the URL below, and unzip to c:\java\setup (creates JavaService
subdirectory):

http://faculty.washington.edu/rfish/code/JavaService.zip

3. In c:\java\setup\JavaService\bin, double-click installTomcat4.1.30.bat (modify this file if you’ve


installed to a different directory).

4. Open the Windows services dialog (Start -> Settings -> Control Panel->Administrative Tools ->
Services) and verify that you now have a “Tomcat_4.1.30” service. Right-click on it and select
Properties. Under Startup Type, select “Automatic” from the dropdown if it is not selected already.
Click OK to close the dialog, then Click the start icon (right-pointing triangle) to start Tomcat up.

Modifying the delivered Tomcat port:

1. To modify the port, we need to change the Tomcat server configuration file, server.xml. Close
Tomcat if it is running, then open C:\java\jakarta-tomcat-4.1.30\ conf\server.xml in a text editor.
It’s a good idea to make a backup copy of this file before you open it.

2. Find a section about 90 lines from the top of the file that looks like the one below:

<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->


<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />

The XML attributes we want to change are “port” (to 9162) and redirectPort (to 9163). The
redirect port does not really have to be change, but it’s a good idea. Here’s then changed version,
with the changes bolded and in red:

<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->


<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="9162" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="9163"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />

3. When you’ve completed step (2), start up Tomcat, and the URL below should bring up the Tomcat
home page:
http://localhost:9162/

http://faculty.washington.edu/rfish/doc/java_tomcat_setup.pdf
Configuring the Tomcat manager application:

The Tomcat manager application can be used to perform various system administration functions
on a running Tomcat server. Use the following steps to configure it:

1. Stop Tomcat if it’s running.

2. Open C:\java\jakarta-tomcat-4.1.30\conf\tomcat-users.xml

3. Add a <username> XML element similar to the one below, replacing the username and password
attribute values with values you create:

<user username="myadminuser" password="myadminpswd" roles="manager"/>

4. Save tomcat-users.xml, then start up Tomcat and surf to the URL below, entering the username
and password from step 3 when requested:

http://localhost:9162/manager/html/

You should see the manager page, where you can stop and start web applications, add new ones
(we’ll do that in the section below), etc.

http://faculty.washington.edu/rfish/doc/java_tomcat_setup.pdf

You might also like