Installing and Configuring Eclipse with Tomcat in Windows

September 12 20094 Commented

Categorized Under: Java

This tutorial is based on the following software environment.

Windows Vista Home Premium, Eclipse 3.5, JDK 1.6, Tomcat 6

Go to http://www.eclipse.org/downloads/ and download Eclipse IDE for Java EE developers for Windows. Once the download is complete, unzip the file to a convenient directory in your system. It is always better to keep short names for your Eclipse path but not mandatory.

eclipse_install1

Since Eclipse is based on Java, we need Java Run-time Environment (JRE). Let us download JDK. Go to http://java.sun.com/javase/downloads/index.jsp and download Java SE Development Kit for Windows.

Once the download is completed, double click the .exe file to start installation. If you are using Vista edition and User Account Control is turned on, it may ask for your permission to run the application. Accept the license agreement.

In next screen it asks for optional features to be installed along with the path to which JDK will be installed. You may disable any feature and change the installation path. For the time being let us select the the default options. Press Next button.

jdk_install1

Installation process starts. During installation, it prompts you to select the destination folder for JRE to be installed. Keep the default path. Press Next button. Click finish button once installation is completed.

OK, let us check whether JRE is installed properly. Go to command prompt and type

java -version

If JRE is installed correctly, you get status message.

jdk_install2

Well, now we have to get Tomcat server. Go to http://tomcat.apache.org/ and download it. The installer is available in two formats, one in .zip and another in Windows service installer. We require the .zip format.

Unzip the file to a convenient location.

tomcat_installation1

 Now we have to setup one environment variable JAVA_HOME

Go to Control Panel–>System–>Advanced system settings–>Environment Variables.

environmental_variable

Under System variables, press New button. Enter the variable name as JAVA_HOME and variable value as the path of JDK home directory. Press OK button to save the variable.

environmental_variable1

Let us test whether Tomcat has been installed successfully. Go to Tomcat home directory–>bin and double click batch file startup.bat. If you have enabled Windows Firewall it may prompt you to block/unblock Tomcat. Press unblock button. You could see the following Tomcat console.

tomcat_console

 Now open your browser and type the following URL.

http://localhost:8080

If you could see the default Tomcat home page, you have successfully installed Tomcat server. Shutdown Tomcat server by executing batch file shutdown.bat in Tomcat home directory–>bin directory.

The last step in our tutorial is configuring Tomcat within Eclipse environment. This help us to develop and test within same IDE. Go to Eclipse home directory and run eclipse.exe application. Eclipse asks for workspace. Workspace is the folder in which all Eclipse related projects reside. You may change it if you want to do so or keep it as itself. Press OK button.

eclipse1

Now Eclipse launches. Close the welcome screen. Go to Help–>Help Contents and familiar with Eclipse if you are using for the first time. Try to grasp concepts like perspective, views etc.

Our default perspective is Java EE. Go to servers view. If Servers view is not available go to Window–>Show View–>Servers. Right Click and select New–>Server.

eclipse2

New server wizard appears. Keep server’s host name as localhost since we are running in our local PC. Select the server type as Tomcat server under Apache. Since I installed Tomcat server version 6, I have selected Tomcat v6.0 server. Press next button.

eclipse3

In next screen we have to specify the tomcat installation directory. Click browse and the select the Tomcat directory. Press Finish button.

eclipse4

Now the server entry appears in Servers view. Right click on it and select Start. Server start and status message appears in view.

eclipse5

 OK, now let us create a project. Go to Eclipse menu File–>New–>Dynamic Web Project. Project wizard appears. Enter the Project name as HelloWorld. Press Finish button.

eclipse6

 Now the project appears in Project Explorer. Right click on WebContent under HelloWorld project and select New–>JSP.

eclipse7

 New JSP page window appears. Give the file name as index.jsp and press finish button. Now index.jsp appears in editor. Write Hello Word between <body> tags and save the file. Now we have to add the project under server. Right click on Server entry and select Add and Remove.

 eclipse8

 Move the HelloWorld project to the right pane and press Finish button. Now the project appears under server.

Now right click on server entry and select Restart to restart the server. Once it is restarted type the following URL in browser and hit enter.

http://localhost:8080/HelloWorld/

Hello World appears on screen. Congratulations! Since index.jsp is the default page we don’t require to add it in URL.

Note: You may be prompted with Windows Firewall screen frequently. If it appears always select unblock option.

cheers

4 Responses to “Installing and Configuring Eclipse with Tomcat in Windows”

  1. Sverix says:

    EXCEPTIONALLY well written. No guessing needed.
    Bravo :-)

  2. Perfect for a beginner, like me ;-)

  3. Nirley says:

    It was very useful. Thnx a lot.

    I think one can skip the step of start.bat

  4. Sunny says:

    Very Good Explanation.. Great Help for Beginners.. Thanks

Leave a Reply

*