Monday, August 2, 2021

How to Attach Apache Tomcat Server in Eclipse for Running and Debugging Java Web Application - Steps

Hello Java programmers, If you are doing Java Web development in Eclipse, then you definitely would like to run and debug your Java application right from Eclipse. To do so, you need to add Apache Tomcat in the Eclipse version you are using, like Eclipse Kepler, Oxygen, Photon, or Luna. Eclipse comes in multiple flavors, like Eclipse IDE for Java Developers, which is suitable for developers doing core Java work, and Eclipse IDE for Java EE developers, which is for people doing enterprise Java work, like developing Servlet, JSP, and EJB based applications in Eclipse. In fact, the Java EE version of Eclipse is also one of the most downloaded software built with Java, so far, more than 1 million programmers have downloaded it.

To install Apache Tomcat, you need to download Eclipse IDE for Java EE developers. Make sure you download a correct version based upon the operating system and architecture you are running to avoid issues related to 64-bit and 32-bit.

For example, if you are running with Windows 10 on a 64-bit HP laptop, then you should download Eclipse IDE for Java EE developers 64-bit version, and you should also have 64-bit JDK installed on your machine.

Once you have installed the Java EE version of Eclipse, follow these steps to add Tomcat into Eclipse Luna or Mars. The latest version of Eclipse also has support for Java 8 and newer versions and it is known as Eclipse 4.14,

Btw, if you are new to Eclipse and want to learn Eclipse in-depth then you can also join these best Eclipse IDE courses for Java programmers.  It's a great course for beginners and you will learn many exciting features of Eclipse IDE which will improve your productivity.





Steps to add Tomcat into Eclipse IDE

If you have not downloaded Apache Tomcat or any other version, then the first step is to download tomcat. You can either download a Windows installer or a ZIP file containing all the files required to run tomcat on Windows.

Once you installed tomcat into your machine, follow these steps to add it as Server run time in your Eclipse IDE.

Please make sure that you have Eclipse IDE for Java EE developers because the Server option is only available on that; it's not available on Eclipse IDE for Java developers.

Here are the steps to add Tomcat into Eclipse :

1) Go to Windows and Open Preferences


How to Setup or Attach Apache Tomcat  Server  in Eclipse for  Debugging Java Web Application - Steps

Remember this will only be available in Eclipse for Java EE developers, for example, in the above screenshot, it's not visible because of this Eclipse IDE for Core Java developer and not for Java EE.

2) Click on the Server node

3) Click on Runtime Environments node
This will open Server Runtime Environments windows, which allow you to add, remove, or edit server configuration. To add Tomcat, just click add

How to Setup or Attach Apache Tomcat  Server  in Eclipse


4) Choose the Server Runtime Environment
Eclipse list down all kinds of Server and their versions it supports, e.g. under Apache node, you can see Apache tomcat v3.2, 4.0, 4.1, 5.0, 5.5, 6.0, and 7.0. You also have nodes for JBoss and ObjectWeb. Since we are adding Tomcat 7, just choose Apache Tomcat v7.0.

5) Enter details of Tomcat Installation
Once you choose the correct version of the Server Runtime Environment, it will open the screen to specify details about your Tomcat Server installation,. you can specify the name, by default Eclipse populates "Apache Tomcat v8.0" which is good enough.

Next, click the Browse button to locate the Tomcat installation directory in your machine and select the tomcat folder, like C: programmer file.

You also have the option to download and install the Tomcat server here on this screen. So if you have not downloaded Tomcat already, you can use this option.

Next is to choose the workbench JRE. This will be used to run Tomcat because it needs Java Runtime.

How to Setup or Attach Apache Tomcat  Server  in Eclipse for Running and Debugging Java Web Application - Steps


That's all, you have added Tomcat into your Eclipse IDE. These steps are valid for all recent Eclipse versions, like Kepler, Luna, or Mars. Just make sure you have downloaded Eclipse IDE for Java EE Developers and its 32-bit or 64-bit installer depending upon your machine's configuration and JDK you are running. To run 64-bit Eclipse, you need 64-bit OS like Windows 8 or Windows 10 and 64-bit JDK installation. You can even follow the same steps to add JBoss Server into Eclipse IDE.

Further Reading
The Java Developer RoadMap
Top 30 Eclipse keyboard shortcuts for Java Programmers
10 Tips to debug a Java Program in Eclipse
3 Maven Eclipse Tips for Java Developers
How to remote debug Java program in Eclipse
5 Free Courses to learn Eclipse and JUnit
10 Tips to become a better Java Developer
10 Tools Every Java Developer Should Know


Thanks for reading this article so far. If you like this article then please share it with your friends and colleagues. If you have any question or feedback or facing any problem while setting up Eclipse for remote debugging then please drop a comment and I'll try to help you out.

P. S. - If you want to learn Eclipse and looking for free resources like the online course then you can check out this Eclipse Tutorial For Beginners: Learn Java IDE in 10 Steps by my blogger friend Ranga Karnam on Udemy. It's completely free, all you need is to create an Udemy account to access this course.

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.