Configuring Apache Tomcat in Eclipse

Integrating Apache Tomcat in Eclipse
So I put this huge idea of mine (an exaggeration really) into a web app and wanted to run it on Tomcat. However, exporting the project to WAR file, deploying it on Tomcat and starting the web server was too much to do every time I made a simple change in the project. So I decided to configure the server inside Eclipse so that deploying and running the project on Tomcat was just a couple of clicks away now. Here’s how I did it:

  1. Click on Window menu and choose Preferences option from it. Out of the options available in left panel, select Server → Runtime Environments. The window should appear as below:
  2. server -> runtime environments

    server -> runtime environments

  3. Click on Add… button. From the new menu that appears, expand Apache option and select the appropriate version of your Tomcat server. As shown below:
  4. Add Server Dialog

    Add Server Dialog

  5. Click “Next >” button. Eclipse gives a default name to the new server run-time configuring you are creating now. I prefer to leave it as is (which in current case is Apache Tomcat v5.5). Next option is to choose the Tomcat installation directory. Click on Browse button and select the location of the installation directory where Tomcat is installed. This directory should be the one inside which “bin, conf” etc folders are present (in my case this directory path is: “D:Softwaresapache-tomcat-5.5.27”. The last option is to define the Java Runtime Environment (JRE). Most likely, if you are reading this post, this would be already configured on your system. I prefer to stay with the workbench default JRE. As shown below:
  6. Tomcat Installation Directory

    Tomcat Installation Directory

    Click on Finish. The new run-time environment configuration should appear as below in the preferences menu:

    new run-time config

    new run-time config

  7. Now, to execute the project, right click on the project. From the pop-up go to Run As → Run on Server (Alt + Shift + X, R). From the list shown, select your appropriate Apache Server version as done earlier. The three text boxes should appear as below:
  8. Select Apache server version

    Select Apache server version

    Here the Server runtime environment should be pre-populated with recently configured Run- time environment name (Apache Tomcat v5.5). Click “Next >”.

  9. Choose your project from the list of Available Projects in left panel and move it to Configured projects’ list by clicking on “Add >” button. As shown below:
  10. Configure projects

    Configure projects

  11. Click Finish. If all goes fine, the server should get started and logs should be visible in the Console view of Eclipse (And if you are lucky enough, your project should get started as well LOLzz):
  12. Server start-up and execution

    Server start-up and execution

Rate this post

Leave a Reply