Tomcat is a popular web server and Java servlet container, and Eclipse is the most widely used IDE for Java development. Therefore, these two programs are usually used together in Java EE development. Though Eclipse has great support for working with Tomcat, it does not include this server in its installation package, so we have to add Tomcat manually. In this article, we describe the steps to bring Tomcat to Eclipse IDE.

Basically, there are two ways to add an installation of Tomcat in Eclipse:

    • Way #1: You already installed Tomcat on your computer, and just add it in Eclipse.
    • Way #2: There is no Tomcat installation exists, so you can download and install Tomcat from within the IDE.
Now, let’s go through each way in details.

 

1. Adding an existing installation of Tomcat

In Eclipse IDE, go to menu Window > Preferences. Then expand the Server > Runtime Environments node in the Preferences dialog:

Select Server Runtime Enviroments in Eclipse

Click Add… to add a new server runtime environment. In the New Server Runtime Environment dialog, select Apache > Apache Tomcat v7.0 (the latest version of Tomcat to date) and check the option Create a new local server:

new server runtime environment

Click Next. In the next screen, click the Browse button to specify the existing installation directory of Tomcat on your computer:



Specify Tomcat installation directory

Click Finish, the selected Tomcat installation is added to the list of server runtime environments, as shown below:

Apache Tomcat is added to the list

Click OK to close the Preferences dialog, the new server runtime is added to the Servers view:

Tomcat in Servers view

You can now drag and drop a project into this server in order to deploy and run the project.

NOTE: If you don’t see the Servers view, you can show it by go to the menu Window > Show View > Others…, then look for Servers.

 

2. Download and install Tomcat within Eclipse

In this way, we can choose to download and install a specific version of Tomcat if one does not exist on local computer. Follow the first two steps as above. Then, instead of specifying an existing installation directory of Tomcat, type the path of the installation directory in the Tomcat installation directory field, and click the Download and Install… button:

Click Download and Install Tomcat

The Download and Install dialog appears:

Install Tomcat - Accept License

Make sure the option “I accept the terms of the license agreement” is selected, and click Finish. Then Eclipse asks to select Tomcat installation directory (the specified path is selected by default), click OK.

Wait for some minutes while Eclipse is downloading and installing Tomcat (you can notice the progress in Eclipse’s status bar), and then click Finish.

 

Other Tomcat Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#13Jorge Hernandez2020-05-16 14:27
Excelente contenido. Muy puntuales y bien explicados los procedimientos. Gracias. Saludos desde Bogotá D.C. (Colombia).
Quote
#12Hiren Ranparia2020-04-18 03:14
Quoting bhargavi:
hello
how to connect tomcat 9 to eclipse photon 2019-9
there is no server option to connect
can you help me



Please install "Eclipse JST Server Adapters" plugin from market place

After plugin installation you will be able to see Window -> Preference -> Server -> Runtime Environment
Quote
#11vuta2020-03-08 07:08
im not robot
thank for share me
Quote
#10Nam2020-02-07 23:47
Hi Anh,
You should not call servlet using its fully qualified name like that. You must call a servlet using its mapping URL.
Quote
#9Anh2020-02-05 14:02
Hi,
Installed Tomcat 9 within Eclipse
Tomcat9 server is started
load the webpage but got error
Type Status Report
Message /sorm/servlet/com.sorm.common.SORMLogin
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Quote