Setting up Tomcat Development in Eclipse

In this post I’ll outline how to get the Tomcat source code up and running in Eclipse. This is the opposite of what most people want to do: debug web applications using Tomcat in Eclipse. This is about downloading the source code, building, and debugging Tomcat itself.

We’ll be using Linux as the development environment, but any sensible environment should work with a few tweaks. I’m also using the latest version of the 1.6 JDK.

Getting the Source

The first thing you’ll need to do is to download the sources for Tomcat. There are a couple of ways to do this, but I’m going to use the up-to-date SVN repository for the trunk. So, open a shell and enter the following:

mkdir /tmp/tomcat
cd /tmp/tomcat/
svn co
cd trunk/
echo "base.path=/tmp/tomcat/trunk/downloads" >
ant download
ant -f extras.xml

Creating the Eclipse Project

Now we turn our attention to setting up an Eclipse project that can build and execute Tomcat.

First, open Eclipse and start with the workspace of “/tmp/tomcat/trunk”. Create a new project using the “Java Project from Existing Ant Buildfile” option. Browse to the file “”/tmp/tomcat/trunk/build.xml” and use the “compile” target, then click “Finish”.

Immediately you’ll see hundreds of errors – don’t panic! We’ll fix these up by updating the classpath. View the project options for our new project and select to edit the “Java Build Path”. We’ll need to remove the “/tmp/tomcat/trunk/${ant.jar}” as this points to nothing (yet). Also remove the “JRE_LIB” entry as this is deprecated (so, why did Eclipse create it???).

To fix up the classpath, do the following:

  1. Click “Add External JARs” and add the JAR found at $ANT_HOME/lib/ant.jar
  2. Click “Add External JARs” and add the two JARs in /tmp/tomcat/trunk/output/extras/webservices
  3. Click “Add Library”, select “JRE System Library”, click “Next”, and then select the default (1.5/1.6) JDK and click “Finish”.

After closing the project properties, the workspace should build and — hopefully — there will be no more compilation/dependency errors.

Running Tomcat

Let’s now get Eclipse to run Tomcat from our source:

  1. Right click on the project, select “Run As…”
  2. Create a new “Java Application” configuration with a main class of “org.apache.catalina.startup.Bootstrap”
  3. Click on the “Arguments” tab and enter the “Program arguments” of “start”
  4. Select a “Working directory” of “Other” with a value of “${workspace_loc:Tomcat 6.0}/../output/build”
  5. Click “Run”

To verify that everything is working, point your browser to:


Hopefully this will help you set up your project in Eclipse to start hacking on the source code to Tomcat.