Sunday, October 28, 2012

Setup the Java Servlet development environment tutorial


This tutorial provides step by step instructions to setup the Java development environment required to test various servlet examples given throughout all the tutorials. This tutorial will also be helpful when you start practicing servlets yourself.

List of required softwares:

  1. Java Software Development Kit (JAVA SDK)
  2. Tomcat
  3. Eclipse for Java

Note: this tutorial explains how to install required software on your windows based PC only.
First of all you need the Java software development kit (JAVA SDK) to be installed.

Checking if JAVA is already installed in your system

Follow this step to check if Java software development kit (JDK) is already installed in your system.
To determine if JAVA SDK is already installed in your system, run the following command from command prompt.

> Java –version
If  JAVA platform is already installed, it will display the version of the JAVA SDK. Below screen shows JAVA version 1.6 running on a windows system. If command executes successfully and shows JAVA version 1.6, you can skip the next step. Otherwise download and install the Java SDK as explained in next step.









Install JAVA SDK

First thing you need to install is Java software development kit (Java SDK) . Download the Java development kit 7 (JDK 7) from Sun Java SE Download site. Current latest version is JDK 7 update 7.

Set up the JAVA_HOME environment variable

Once the JAVA SDK is installed follow this step to set the JAVA_HOME environment variable. If JAVA_HOME variable is already set, you can skip this step.

Right click on My Computer icon on your desktop it will open a popup menu, click on properties, it will open the system properties window, then click on advanced tab.


Click on environment variables button, it will open the environment variables window as shown in figure below. Initially there will be no JAVA_HOME environment variable set as shown in figure.



Click on new button to add new system variable JAVA_HOME.



In the variable name filed, enter JAVA_HOME. Specify the path to root directory of JAVA installation in variable value field and click OK button. Now JAVA_HOME will appear under user variables.

Next you need to add bin directory under the root directory of JAVA installation in PATH environment variable.Select the PATH variable from System variables and click on Edit button.

Add: ;%JAVA_HOME%\bin; at the end of variable value field and click OK button.

Now verify that everything is correct by following the step: Checking if JAVA is already installed in your system. It should show the version of the installed JAVA SDK.