Integrating Tomcat Into EclipseS2C Home « Integrating Tomcat Into Eclipse

In our third lesson on the Eclipse IDE we look at integrating Tomcat into the Eclipse IDE. This lesson assumes you have downloaded Tomcat 6 as explained in the Tomcat 6 For Eclipse lesson (or Tomcat 7 or Tomcat 8 where appropriate) as the integration works exactly the same. So anywhere you see Tomcat 6 in this lesson just change it for the version you are integrating.

Rename Eclipse Filesgo to top of page Top

The first thing we need to do is change a couple of filenames that come with the distribution and were deployed into the directory you built Tomcat in which for me was C:\tomcat6\trunk. The files are named eclipse.classpath and eclipse.project and are shown in the following directory listing:

Eclipse trunk directory

These files need to be renamed to .classpath and .project and the following screenshot shows this being done on my Windows7 system and the updated directory listing:

Rename classpath and project files

Setting Classpath Variablesgo to top of page Top

We need to add a couple of classpath variables to our build path, so from the menu bar at the top of the workbench select Window | Preferences to display the preferences dialog screen. From the left pane go down to Java | Build Path | Classpath Variables and add entries for ANT_HOME which should point to the base directory for your Ant installation and TOMCAT_LIBS_BASE to point to the directory that holds the files downloaded via ant download. I just used the default when I ran the ant download so for me the base path was C:\usr\share\java.

The following screenshot shows the classpath variables (highlighted in yellow) after we have added them:

Eclipse workspace launcher

Import Project Into Eclipsego to top of page Top

Ok we are now ready to import the project into our Eclipse ID and to do this from the top menu select file | import to open the import dialog box. Open the General tag and select Existing Projects Into Workspace and press the Next button as shown in the following screenshot:

Eclipse welcome

Browse to where your trunk for the Tomcat 6 download is which for me is C:\tomcat6\trunk and you should end up with a screen like the following:

Eclipse welcome

Press the Finish and you should see the project built within Eclipse and you should end up with a screenshot similar to the following:

Eclipse welcome

Starting The Tomcat Servergo to top of page Top

The last thing we need to do is create a run configuration so we can start up our Tomcat Server from within Eclipse. from the top menu select Run | Run Configurations... and drill down to Java Application and create a Bootstrap configuration using org.apache.catalina.startup.Bootstrap as the main class and click the apply and run buttons as shown in the following screenshot:

Tomcat run configuration

Hopefully you should see Tomcat starting up in the console pane. Lets verify it worked by going to a web browser and typing in http://localhost:8080/ to verify Tomcat is running as shown in the following screenshot:

Tomcat running

Lesson 3 Complete

In this lesson we integrated Tomcat 6 into the Eclipse IDE and ran the server from within the Eclipse IDE.

What's Next?

That's it for the Eclipse section of the site and concludes the lessons on the site.

go to home page Homepage go to top of page Top