Wednesday, December 9, 2009

Tomcat with Eclipse

This is a short tutorial to learn how to run Apache Tomcat server using Eclipse. Lets do it step by step.

  • Install Apache Tomcat 6.0 from here.
  • Unzip the zip file onto your local machine.
  • Now to run the Tomcat server, you need to go to command prompt. So type cmd.exe in Run. Am using the Windows platform. In the command prompt, go to the Apache folder/bin folder
  • Type in SET JAVA_HOME= The location where JDK is installed. In my case, C:\jdk1.6.0.
  • Now run startup.bat
  • This is the way to run the server for a single instance. The best way to avoid typing this command everytime you need to start server, is to modify startup.bat and shutdown.bat. So edit these 2 files by any editor like Notepad, EditPad or Wordpad and include the command SET JAVA_HOME=C:\jdk1.6.0
  • When you run startup.bat, you see another window of command prompt opening, detailing the initializtion and starting of the server. (For instance, typically the message ends with the line - INFO: Server startup in xxxx ms, where xxxx = the time taken to startup like 4318ms or 5124ms... anything).
  • To check if the server has started, go to your web browser and type in http://localhost:8080/ in the address bar. You should see a congratulations message. On the left panel of the page you can manage the server using administration tools.
  • In order to manage the server, you need to have the managing rights for access. So go the installed directory of Apache tomcat/conf folder. Edit the tomcat-users.xml file and add the following command:  
  • So far we learnt how to install the tomcat server on the local machine. Lets now see how to run it using Eclipse. There are many plugins for Eclipse. The most preferred one is the Sysdeo tomcat plugin. Download it here.
  • After you download the zip file of the plugin (latest version is the 3.2.1), unzip it and cut/paste in the "plugins" folder of Eclipse's installed location. 
  • Now start Eclipse.

  • Go to the Window menu and click Preferences.

  • In the preferences, you need to make changes for Tomcat. So choose the appropriate Tomcat version you're using. Also specify the Tomcat home i.e the exact location of where Tomcat is installed. Apply the settings.

  • So this is how you can start and stop Tomcat server using Eclipse. See the following change on the menu bar of Eclipse.

Stumble Upon Toolbar

No comments:

Post a Comment

Related Posts with Thumbnails