How do I create a utility project that multiple projects can share?
Author: Deron Eriksson
Description: This Java tutorial describes how to debug a utility project from another project in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1 || Tomcat 5.5.20

Page:    1 2 >

Over time, when working on JavaSW projects, you will probably find yourself requiring certain classes that you've written over and over. A good solution is to have one copy of the classes in a 'utility' project that you turn into a jarW file that gets included with each of your projects.

If you needed to modify these classes while working on an application, how would you do so? Rather than including the utility jar file in the classpathW of your project, you can include the utility project in the classpath of your project. In this way, you can modify and work on classes in your utility project while debugging your Java application.

In this tutorial I'll utilize the Java web application project that I set up in EclipseSW for another tutorial.

I'm going to demonstrate debugging a utility project via a Java web application project that I'm debugging in TomcatSW. First, I create a Java project and call it 'utility-demo'. I create one class in the project, a simple UtilityDemo class that has a single method that returns a String.

Navigator View in Eclipse

package demo;

public class UtilityDemo {

	public String getMessage() {
		return "UtilityDemo says hello";

Now I'll add the utility-demo project to the classpath of the 'tomcat-demo' project that I created in the "How do i debug my web project in Tomcat from Eclipse without plug-ins?" tutorial. I right-click 'tomcat-demo' and go to Properties.

'tomcat-demo' properties

Next I go to Java Build Path and click the Projects tab. Then I click the Add... button and select the 'utility-demo' project and click OK.

Projects Tab of Java Build Path

Now that the utility-demo project is added to tomcat-demo's classpath, I click OK.

'utility-demo' project added to build path of 'tomcat-demo' project

(Continued on page 2)

Page:    1 2 >