Alexey Zvolinskiy

About Alexey Zvolinskiy

Alexey is a test developer with solid experience in automation of web-applications using Java, TestNG and Selenium. He is so much into QA that even after work he provides training courses for junior QA engineers.

Tomcat in Eclipse: 6 popular “how to” questions

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">
</connector>

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

 

Reference: Tomcat in Eclipse: 6 popular “how to” questions from our JCG partner Alex Fruzenshtein at the Fruzenshtein’s notes blog.

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

Leave a Reply


− four = 5



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books