Eclipse IDE for J2EE 1.3 Development
(Tomcat 4.1.24)

by Hao Wu

extended with permission by Tyler Strickland (tylerATtylersDOTorg)

Click here for the original document

Last modified: 05/16/2003

Purpose
This article covers setting up the following Open Source tools for J2EE 1.3 development.

- Jakarta Tomcat 4.1.x
- Eclipse Java IDE

* These instructions assume a Windows platform. Linux needs slightly different URLs & similar steps.
* Following the order herein is recommended.

Quick Reference

Software
(Click for details)

Current Version

Vendor

Description

Installation

JDK

1.4.1_02

Sun

J2SE 1.4

Install

Tomcat

(Open Source)

4.1.24

Apache

J2EE 1.3
(Servlet 2.3, JSP 1.2, etc.
)

Unzip

Eclipse

(Open Source)

2.1

Eclipse

Java IDE

Unzip

Eclipse Tomcat Plugin

0.96

Sysdeo

(France)

IDE Plugin

Unzip


Installing JDK

Version

1.4.0

Download

Get binary j2sdk-1_4_1_02-windows-i586.exe at http://java.sun.com/j2se/1.4.1/download.html
* Be sure to download the SDK, not the JRE.

Documentation

- Online – http://java.sun.com/j2se/1.4.1/docs/index.html
- Downloadable – http://java.sun.com/j2se/1.4.1/download.html

Install

Run the executable which will install the following:

  • Java 2 SDK, SE v1.4.1_02

  • Java 2 Runtime Environment, SE v1.4.1_02

  • Java Plug-in 1.4.1_02

  • Java Web Start

Environment

Set variable JAVA_HOME to <install dir> (e.g. C:\j2sdk1.4.1_02).

Make sure <install dir>\bin is in your PATH (e.g. C:\j2sdk1.4.1_02\bin).

Test

Open a DOS window (Start -> Run... -> cmd), try java -version and you should get:

java version "1.4.1_02"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)

Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)


Installing Tomcat

Version

04/01/24

Download

Get zip binary at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/bin/jakarta-tomcat-4.1.24-LE-jdk14.zip
(General download at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release .)
* Also available is an Install version, which can run as Windows service. Not recommended for development.

Documentation

- Online - http://jakarta.apache.org/tomcat/tomcat-4.1-doc/index.html
- Local - (after installation) at
%TOMCAT_HOME%\webapps\tomcat-docs\index.html
(Also accessible at
http://localhost:8080/tomcat-docs/index.html, if Tomcat is started on port 8080)  

Install

Unzip to destination (say C:\, which makes <install dir> to be C:\jakarta-tomcat-4.1.24-LE-jdk14).

Environment

Set variable TOMCAT_HOME to <install dir> (e.g. C:\jakarta-tomcat-4.1.24-LE-jdk14).

Test

"cd %TOMCAT_HOME%\bin" and "startup" (startup.bat), you should see ---

Apr 9, 2003 1:47:27 PM org.apache.commons.modeler.Registry loadRegistry

INFO: Loading registry information

Apr 9, 2003 1:47:27 PM org.apache.commons.modeler.Registry getRegistry

INFO: Creating new Registry instance

Apr 9, 2003 1:47:28 PM org.apache.commons.modeler.Registry getServer

INFO: Creating MBeanServer

Apr 9, 2003 1:47:29 PM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on port 8080

Starting service Tomcat-Standalone

Apache Tomcat/4.1.24-LE-jdk14

Apr 9, 2003 1:47:34 PM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on port 8080

Apr 9, 2003 1:47:34 PM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8009

Apr 9, 2003 1:47:34 PM org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=0/40 config=C:\jakarta-tomcat-4.1.24-LE-jdk14\bin\..

\conf\jk2.properties

Now that Tomcat is up, access http://localhost:8080 from your browser.

You can stop the server by selecting its console window and typing Ctrl-C

Other

o Installing Sysdeo Eclipse Tomcat Launcher Plugin (refer to the later section)


Installing Eclipse

Version

2.1

Download

Get zip binary at ftp://download.eclipse.org/R-2.1-200303272130/eclipse-SDK-2.1-win32.zip
(General download at http://www.eclipse.org/downloads/index.php)

Documentation

- Eclipse FAQ: http://www.eclipse.org/eclipse/faq/eclipse-faq.html
- Documentation site: http://www.eclipse.org/eclipse/index.html (Currently only 1.0 docs)
- Searching News/Mailing archive: http://www.eclipse.org/search/search.cgi

Upgrade from Previous Version

- Rename your previous installation (say C:\eclipse to C:\eclipse_old). And remove it after you get the new version up for a while.
- After the installation, copy your workspace over (from C:\eclipse_old\workspace\ to C:\eclipse\workspace).
- After the installation, go over other Eclipse related sections and check for applicable changes.

Install

Unzip to destination (say C:\, which makes <install dir> to be C:\eclipse).

Create a shortcut on your Start Menu or Quick Launch to c:\eclipse\eclipse.exe

Test

- You should have a JDK installed (if you use Sun JDK, 1.4.0 is recommended for hot code replacement support).
- Start Eclipse and it would detect the JDK (through %JAVA_HOME%)
- You can also manually specify VM (option -vm <javaw.exe location>)
- Specify workspace location if don't want the default (option -data <workspace location)

Other

Tomcat Plugin for Eclipse (see below)


Installing Sysdeo Eclipse Tomcat Launcher Plugin

Version

V21

Download

Get binary tomcatPluginV21.zip at http://www.sysdeo.com/eclipse/tomcatPluginV21.zip
(General page at http://www.sysdeo.com/eclipse/tomcatPlugin.html .)

Documentation

Online instructions: http://www.sysdeo.com/eclipse/tomcatPlugin.html

Upgrade from Previous Version

- If you did NOT just install a new version of Eclipse, remove the old plugin directory (for example, C:\eclipse\plugins\com.sysdeo.eclipse.tomcat\)

 

Install

Unzip to <Eclipse install dir>\plugins\ (the plugin will reside under <Eclipse install dir>\plugins\com.sysdeo.eclipse.tomcat).

Configure Eclipse

  1. Start Eclipse.

  2. Configure the Tomcat plugin:
    Click Workbench -> Preferences.

  3. Open the category Tomcat

  4. Set the Tomcat version to "Version 4.1.x"

  5. Set the preference Tomcat Home to the <Tomcat install dir>

  6. Under suboption JVM Settings -> Classpath, add the Jar/Zip for tools.jar. (If you use JDK 1.4 at C:\jdk1.4, it is "C:\jdk1.4\lib\tools.jar"). This is for compiling JSP's.

  7. Open the main option Java -> Classpath Variables -> New variable

    Name: "TOMCAT_HOME", value: <TOMCAT install dir>

  8. Click OK

Note:
For your Eclipse project, .classpath needs this to compile Servlets:

<classpathentry kind="var" path="TOMCAT_HOME/lib/jasper-runtime.jar"/>
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/servlet.jar"/>


Installing the Sysdeo Tomcat JSP Debugging Patch

Version

4.1.24 (Corresponds to the Tomcat version installed)

Download

Get zip binary at: http://www.sysdeo.com/eclipse/jasperDebugPatchV4.1.24.zip
(General page at http://www.sysdeo.com/eclipse/tomcatPlugin.html )

Documentation

Online instructions: http://www.sysdeo.com/eclipse/tomcatPlugin.html

Install

To install this patch, unzip the file in <%TOMCAT_HOME%>/common/classes for Tomcat 4.1.x (See the above site for earlier versions of Tomcat)


Creating your project:

  1. Create a new Tomcat Project:

    File -> New -> Project -> Java (on left) -> Tomcat Project (on right). Click Next. Name the project. Click Finish.

  2. Make sure Tomcat menu is accessible.

    Select the Java Perspective (the icon on the left with the J in it) and add the Tomcat buttons to it:

    Window -> Customize Perspective. Other -> check the Tomcat option

  3. Use menu or toolbar to Start/Stop Tomcat (The plugin will start/stop Tomcat as a debugging mode VM inside Eclipse, so debugging into Servlets and JSP-generated-Servlets becomes possible.)

  4. Unzip the project source into the directory of the new project, c:\eclipse\workspace\<project name> for example.

  5. Right click on the project name in the left window of Eclipse and select Refresh. The project will compile with errors. Don't worry about them.

  6. Right click on the project name in the left window of Eclipse and select Properties.

  7. Click on Java Build Path. Under the Source tab, click Add Folder. Select the <project name>/src folder. Click OK.

    It will ask you: Do you want to remove the project as source folder and update build output folder to <project name>/bin? Click Yes

  8. Click on the Libraries tab. This is where you will add any required libraries, such as idb.jar (for InstantDB) using the Add External Jars button.

  9. Click on the Tomcat menu on the left.

  10. Check the Is this a Tomcat project checkbox.

  11. Check the Redirect context logger to Eclipse console checkbox.

  12. Set the Subdirectory to set as web application root to /webroot/

  13. Click OK, then OK again when it asks you about the new output folder.

  14. Right click on the project name. Choose Tomcat project -> Add Tomcat libraries to project build path

  15. Add the context: Right click on the project name. Choose Tomcat project ->Update context in server.xml

  16. Remove it: Right click on the project name. Choose Tomcat project ->Remove context in server.xml

  17. Add it again: (We do this to bypass a bug in the default Tomcat setup)

    Right click on the project name. Choose Tomcat project ->Update context in server.xml

  18. Go to Window -> Preferences; Tomcat menu. Add your project to the Tomcat classpath.

19.We also need to remove the comments around the default invoker from the file <TOMCAT_ROOT>\conf\web.xml

1. Open the file in a text editor like notepad (NOT Word) and look for a section like the following:

<!-- The mapping for the invoker servlet -->

<!--

<servlet-mapping>

<servlet-name>invoker</servlet-name>

<url-pattern>/servlet/*</url-pattern>

</servlet-mapping>

-->

2. Remove the comments around the servlet mapping section (the <!-- and --> that are on their own lines).

20.You will still have a few warnings in the project, but don't worry about those, they will go away as you work on the project.

21. Look around the Window -> Preferences menu and customize the IDE to your delight. It has many valuable features that will make your life much easier.

Original Copyright © 2002 Purpose Solutions, Inc.
All Rights Reserved

Modified and distributed with permission