Setup Tomcat6 on Eclipse

Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/ and tomcat6 from http://tomcat.apache.org/download-60.cgi

Extract both of them where you prefer. I extracted Eclipse in /opt/eclipse and Tomcat in /opt/tomcat6), then run Eclipse.

When you’ll run eclipse it asks you about creating a new workspace (that will be used to store all of your projects), so create a workspace, usually somewhere in your user home directory.

When Eclipse is up and running, choose preferences from the window menu. Choose from the bar on the left: Server, Runtime Environments.

Preferences window in Eclipse

Preferences

Click the button Add, choose Apache Tomcat 6.

New Server Runtime Environment

New Server Runtime Environment

In the next page, browse on your disk and choose the directory where you previously extracted Tomcat. In my case it’s /opt/tomcat6. Finally click Finish.

New Server Runtime Environment - Server Path

New Server Runtime Environment - Server Path

Well, until now we have just told to our workspace where Tomcat “installation” is located on our disk.

But, if we wish to run Java Web Applications within Eclipse, we should setup a Server and eventually assign to it a specific configuration.
Go in the Servers view, right click and choose New, then Server.

Select “Tomcat v6.0 Server” as server type (or probably it will be automatically pre-selected), then, in the Server Runtime environment select box you’ll have to choose “Apache Tomcat v6.0″ (that’s probably the only available option.

New Tomcat Server in Eclipse

New Tomcat Server in Eclipse

Click on Next, Eclipse will prompt you to eventually add (or remove) web projects from this Server, in this case, if your workspace is empty you’ll have not any project to add. So, click Finish.

eclipse-add-remove-projects-from-tomcat

Add remove Eclipse projects from Tomcat

In the Servers panel, you will see the Tomcat you just added, and in the Project Explorer view, a new Server configuration will magical appear.

So you can edit the configuration file server.xml as you prefer, change AJP or HTTP connector ports and so on, start/stop/debug the server and obviously add and remove projects from it.

Editing Tomcat configuration in Eclipse

Editing Tomcat configuration in Eclipse

It is also possible to add other server “instances”, just right click again in the “Servers” view, and follow the procedure described before.

In this way, you will just a single “Tomcat” binaries location (that you defined in the first step of this tutorial), but you’ll have the chance to add many instances of that server, each of them with its specific configuration (imagine the /conf directory of Tomcat) and its specific web application (imagine the /webapps directory).

Multiple Tomcat Instances in Eclipse

Multiple Tomcat Instances in Eclipse

For the more expert ones, it is similar to have more instances on the same tomcat binaries defined on different CATALINA_BASE paths.

I hope this tutorial has been useful, please post any question or comment.

22 thoughts on “Setup Tomcat6 on Eclipse

  1. Very good, indeed!
    Would be perfect if you show how to launch a web application in eclipse thanks to this configuration.
    But it works perfectly.

  2. You forgot to mention that “Create a new local server” must be checked when adding the Apache Tomcat runtime environment.

    • I love the pictures in your blog! I wish we could do this more often. We shloud have thought about this before they were born and we could have done pictures every 3 months I had NO idea that there was video! I LOVE it!!!

  3. Thank you very much. its very clearly explained. i was sooooo confused while reading other articles and blogs, but this one not only felt easy and simple, it also worked for me.
    :D thanks!!!

  4. its really nice having step by step process for configuring tomcat to eclipse. it would be more useful whn u’ll add the how to create the project with explanation like which option would be added for jsp/servlet project… any hw nice explanation to helping the newbies & serious geeks…..

    • Yeah I hear ya about the typos! the few I tried to read I didn’t care for cuz the “tone” of the characters was too off! This one does a prttey good job! There are 2 I read on the TM site that are REALLY good too! I think they were by an amy16 or something like that!

  5. Pingback: Some notes about “Server View” in Eclipse | Tsetso's Stuff

  6. Hi all, I have a problem with configuration of server.xml; I have two application and I want that one is default application.Below my code:

    Someone can help me please?

  7. I can’t paste the code, correct. I define Host appBase=”WebAgency” and Context docBase=”WebAgency” path=”/WebAgency” reloadable=”true” source=”org.eclipse.jst.j2ee.server:WebAgency”; and the second one similar to WebAgency.
    Work correctly with url localhost:8080/WebAgency bat not with url localhost:8080

    • Hi Jason, My Name is Leyla Samiee working in a BI demartpent of a company in Canada. Three months ago we just started getting BIRT on site. No we have the only developer assigned to the job gone and left us in a big mess with no documnetation. We are facing a very critical issue.Would you please contact me if you are willing to help.Regards, –Leyla Samiee lsamiee at sympatico dot ca

  8. I am absolutly skoched!Thank God we have someone wise like you to teach us about things that are dangerous!”…now that you know it has been done, you wont try it at home!! (potentially dangerous).”We would never have guessed that looking at the Sun could hurt our eyes! Amanda, do have you any idea how insulting that statement was?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>