Learning a new technology is always a hard process. This process becomes even more difficult when you are trying to learn two technologies which are going to interact with each other. Tomcat and Eclipse are ones of the most popular pre-requirements in the Java EE development. Therefore to be a professional developer you need to know how to perform the most required actions with this pair and how to make some configurations.

1. How to add Tomcat in Eclipse?

The simplest way is to download Eclipse IDE for Java EE Developers. There if you create a new Dynamic Web Project, Eclipse will download and install Tomcat automatically. But what if you want to do this by yourself?

  1. Firstly you need to download the latest version of Tomcat and install it on your computer. Don’t forget the directory of the newly installed Tomcat
  2. Then open Eclipse and on the main menu choose Window -> Preferences.
  3. In the “Preferences” window select Server -> Runtime Environments from the left panel.
  4. Click on the “Add..” button, after that select the version of Tomcat you have already installed.
  5. Click on the “Next” button, specify the path to the installed Tomcat and press the “Finish” button.

That’s it. Now you can find the server in the “Server” view in your Eclipse.

2. Where is Eclipse-Tomcat working directory?

It’s seems ridiculous when you are working with Tomcat in Eclipse and you don’t know where your server is. In order to find this out, you need to make several simple steps:

  1. Open the “Server” view in Eclipse.
  2. Select the server the location of which you want to know.
  3. Double click on the server.
  4. In the opened window select the “Server location” section.
  5. Take notice of the “Server path” field.

Usually this path looks like this: %eclipse_work_space%\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

3. Where is a log file in Tomcat?

The location of the logs directory in Tomcat (integrated with Eclipse): %eclipse_work_space%\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\logs

4. How to change Tomcat port in Eclipse?

The first way:

To change the HTTP port you should to repeat the first three steps from paragraph #2, then open the “Port” section and set the value for “HTTP/1.1” field (by default value is 8080) to that you want to use.

The second way:

Navigate to %eclipse_work_space%\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf
Open server.xml and find the following string:

<connector connectiontimeout="20000" port="8080" protocol="HTTP/1.1" redirectport="8443" />

Modify the value of the “port” attribute in order to specify the port you need to use.

5. Where to put WAR file in Tomcat?

  • If you integrate Tomcat with Eclipse: %eclipse_work_space%\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
  • If you want to deploy WAR file in standalone Tomcat: %server_location%\webapps

6. Tomcat debug mode in Eclipse

In order to launch Tomcat in debug mode from Eclipse, click on the button with bug icon in the “Server” view (view the image below for more details).

Eclipse Tomcat Debug Mode

About The Author

Mathematician, programmer, wrestler, last action hero... Java / Scala architect, trainer, entrepreneur, author of this blog

Close