IMPORTANT: This is not a supported means of building Tomcat; this information is
provided without warranty :-).
The only supported means of building Tomcat is with the Ant build described above.
However, some developers like to work on Java code with a Java IDE,
and the following steps have been used by some developers.
NOTE: This will not let you build everything under Eclipse;
the build process requires use of Ant for the many stages that aren't
simple Java compilations.
However, it will allow you to view and edit the Java code,
get warnings, reformat code, perform refactorings, run Tomcat
under the IDE, and so on.
Sample Eclipse project files and launch targets are provided in the
res/ide-support/eclipse directory of the source tree.
The instructions below will automatically copy these into the required locations.
An Ant target is provided as a convenience to download all binary dependencies, and to create
the Eclipse project and classpath files in the root of the source tree.
Start Eclipse and create a new Workspace.
Open the Preferences dialog and then select Java->Build Path->Classpath
Variables to add two new Classpath Variables:
|TOMCAT_LIBS_BASE||The same location as the |
build.properties, where the binary dependencies have been downloaded
|ANT_HOME||the base path of Ant 1.8.1 or later|
Use File->Import and choose Existing Projects into Workspace.
From there choose the root directory of the Tomcat source tree (
and import the Tomcat project located there.
stop-tomcat launch configurations are provided in
res/ide-support/eclipse and will be available in the Run->Run Configurations
dialog. Use these to start and stop Tomcat from Eclipse.
If you want to configure these yourself (or are using a different IDE)
org.apache.catalina.startup.Bootstrap as the main class,
stop etc. as program arguments, and specify
(with the name of your build directory) as VM arguments.
Tweaking a few formatting preferences will make it much easier to keep consistent with Tomcat
coding conventions (and have your contributions accepted):
|Java -> Code Style -> Formatter -> Edit...
||Tab policy: Spaces only|
Tab and Indentation size: 4
|General -> Editors -> Text Editors
||Displayed tab width: 2|
Insert spaces for tabs
Show whitespace characters (optional)
|XML -> XML Files -> Editor||Indent using spaces|
Indentation size: 2
|Ant -> Editor -> Formatter||Tab size: 2|
Use tab character instead of spaces: unchecked