Escolar Documentos
Profissional Documentos
Cultura Documentos
Jakarta Tomcat
A quick approach to integrating Eclipse and Tomcat
Level: Introductory
Geoffrey Duck, Software Developer, IBM
20 May 2004
Updated 26 Jun 2006
Using Eclipse as a development environment for Java™ technology is great. Using an Eclipse
Tomcat plug-in can help to better organize and integrate your Java and Web development projects.
This article will guide you step by step through the installation of Eclipse, Jakarta Tomcat, and an
Eclipse Tomcat launcher plug-in that will integrate them.
Download each of the components that you require. The sites where the files are available at the time this article
was published are listed below in the Resources section.
Eclipse IDE: The Eclipse IDE is used as the development environment for your JSP pages and Java files. Eclipse
is an easy IDE to use, with many features that make for quick and painless Java programming and debugging.
With the addition of the Tomcat plug-in, this IDE becomes a great tool for managing entire Web projects,
including HTML and JSP pages, icons, and servlets.
Java SDK: An SDK is required for the Tomcat Eclipse plug-in to function correctly. It does not necessarily have
to be the Sun SDK, but it has to be an SDK, (you cannot use just a JRE as it will not work). There must be a Java
compiler present in the SDK in order for Tomcat to function with Eclipse.
Tomcat: Tomcat is needed to drive your JSP pages. The Tomcat engine is a very good servlet engine that is free
and easy to install.
Eclipse Tomcat Launcher plug-in by Sysdeo: This is just one of the many Eclipse plug-ins for Jakarta Tomcat.
This is a good plug-in that saved me lots of time and integrated my Web projects with my Java code that I would
usually use Eclipse to program.
Installation
Unzip all of the components
Once you have downloaded what you need, the next step is to unzip each file. Unzip them and put them all in the
same directory to keep track of what you are unzipping.
Select the Java option from the left-hand tree view. Expand the Java element and select Installed JRE's, as shown
in Figure 2.
Check the check box beside the JRE you just added from the SDK you installed, as shown in Figure 4. This sets
this JRE as the default JRE to be used by Eclipse. You must do this for the Tomcat plug-in to work. The Tomcat
plug-in requires that an SDK be the default JRE selected in these Eclipse preferences.
Figure 4. Setting the default JRE for Eclipse and Tomcat
Select the version of Tomcat that you installed from the top radio buttons. I used Tomcat V5.0.16 so I have
selected the last radio button option available, Version 5.x.
Next, we have to set the Tomcat Home variable. Next to the Tomcat Home dialog box, click Browse. Browse to
the base directory of the Tomcat version that you unzipped and click OK. The Configuration file will be
automatically selected and filled in for you. If you wish to select another configuration file for Tomcat instead of
this one, you can browse to that file now. Otherwise the default value will work fine.
We have now completed the minimal requirements to start and run Tomcat using Eclipse and the Sysdeo Tomcat
Launcher plug-in. Browse through the remaining preferences for Tomcat in the Eclipse preference dialog. You will
notice that there are many other options available to you in the Tomcat preferences. For example, adding
parameters to the JVM used by the Tomcat server, selecting Java projects from your workspace to add to the
Tomcat classpath, as well as settings to allow the use of the Tomcat management application.
Testing Tomcat and Eclipse together
Create a new Tomcat Project
To test the integration of Tomcat and Eclipse, we will start by creating a new project. Select File > New > Project
and examine the new project wizards contents. There is a new entry available in the Java section of this project
wizard. Tomcat Project is a new option available (see Figure 6). Select it and click Next.
Give your new Tomcat project a name. For example, TomcatProject, as shown in Figure 7. Click Next.
Add the content shown in Listing 1 to your index.jsp file and save it.
Figure 11. Start the Tomcat server using the Sysdeo Tomcat plug-in
The Tomcat server will start and its startup text will appear in the Eclipse workbench's Console view, as shown in
Figure 12. Examine the startup log and watch for any errors.
Figure 12. Tomcat's startup information is displayed in the Eclipse Console view
Summary
You should now have Eclipse set up and configured to work with Jakarta Tomcat. You now have the power to
develop and test quick JSP's with integrated Java code, using a great IDE that will help improve your productivity.
Using Eclipse to program Java code and having it integrated with Jakarta Tomcat will make JSP development fun
and easy.
Resources
Learn
z New versions of Eclipse, Tomcat, and Java technology make some information in this article obsolete. See
"Developing Web applications with Tomcat and Eclipse," by Nathan Good in May 2007 for an update of
this article.
z "What is Eclipse and how do I use it?" provides a lot of information for users new to Eclipse.
z The Jakarta Tomcat Web site contains a plethora of information about Tomcat.
z Expand your Eclipse skills by visiting IBM developerWorks' Eclipse project resources.
z Visit the developerWorks Open source zone for extensive how-to information, tools, and project updates to
help you develop with open source technologies and use them with IBM's products.
z Stay current with developerWorks technical events and webcasts.
z Download the Java SDK V1.4.1 from the Sun Web site.
z Download the Sysdeo Tomcat plug-in from the Sysdeo Web site.
z Innovate your next open source development project with IBM trial software, available for download or on
DVD.
Discuss
z Get involved in the developerWorks community by participating in developerWorks blogs.