Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This of course assumes you installed Tomcat in your Applications folder.

On a Linux server, you might have a service installed to start Tomcat or you can do it similarly to the way you start Tomcat on a Mac .or if you have a service installed to start Tomcat type

Code Block
languagebash
service tomcat6 start

Tomcat will attempt to start all applications that are in Tomcat's 'webapp' folder. You usually deploy an application to Tomcat by putting its war-file into that folder. The Tomcat version from Apache's Tomcat page usually ships with a manager application, that also allows you to deploy applications to Tomcat via the browser.

Tomcat & Eclipse

So far so good. But what happens when you add your Tomcat to Eclipse? The main important thing for you to remember is that Eclipse does not use the Tomcat instance you've installed on your system. It'll create a new Tomcat instance using your installed 'Tomcat Runtime'. This means that if you have web applications in your Tomcat's webapp folder those won't be available when you run Tomcat in Eclipse. Similarly, if you made changes to your Tomcat configuration, those will most likely not be taken up in Eclipse. Usually, you also do not have the manager GUI when running Tomcat from Eclipse.

Configuring Eclipse

As usual, there are several ways to achieve what we want to do. Here, we will go through the "Servers" view as it is a useful view when working with web applications. Go to "Window -> Show View -> Others..."

Image Added

Then select from the folder "Server" the view "Servers". If you do not have such a folder, double-check that you have Eclipse's Web Tools Platform (WTP) installed.

In the view that opens, right click and select "New -> Server". A wizard should open that is called "Define a new Server".

Select the type of server you'd like to create (in our case Tomcat 6). If you choose a type that you used before, you should a property called "Server runtime environment" that shows the runtimes you've already defined. If that is the case, simply make sure it is the correct runtime and click "Finish" and you're done.

Image Added

If you haven't defined a runtime yet, click "Next". The next screen will ask you to tell Eclipse where you Tomcat runtime is installed. Use the browse button to find your Tomcat's installation directory.

Image Added

Click "Finish". The "Servers" view should now show you the Tomcat instance you just added.

Image Added

Note: In the above example, a Tomcat 7 instance was added as a Tomcat 6 instance already existed for the workspace.

Running Tomcat

You can use the "Servers" view to start, stop, and restart your Tomcat instances. Just right click on a server and use the context menu or select the server and use the buttons in the view. If you made changes to your application, you can simply restart your Tomcat through the view, and the changes will automatically be deployed with the restart. You do not have to go through "Run on Server" in the context menu of your project after you restarted Tomcat. Just a restart is usually enough.