In the previous tutorial, I went over what web services are and the benefits they offer. In this tutorial we are going to set up the neccesary environment so that we can get started.
For this to work you need to have the following ready;
- A JDK installed in your machine
- You have downloaded Eclipse Galileo and extracted it – if you haven’t please refer to the previous tutorial.
I am assuming that you now have a copy of Jakarta Tomcat version 5.0 or any other version above this as they all work the same. If you dont have it you can get a copy by following this link . Extract the zipped file you downloaded to any location on your computer. With Jakarta,that is all as we don’t need to do any installation.
This tutorial is going to cover how to configure Tomcat and fire it up from Eclipse.
Setting up the Enviromental Variables
We know need to configure the following;
- CATALINA_HOME – This is the path to Tomcat folder you extracted
- JAVA_HOME – This is the path to your JDK
- CLASSPATH – This is the path to the JDK lib folder and Tomcat lib folder
My configurations are on Windows 7 but it is not much different on other versions of Windows. To set up these variables we are going to follow the following steps;
- On “Computer” icon right click and select “Properties” and then choose “Advanced System Settings“
- You then proceed to the “Environmental Variables“
- You now have to create a new system variable by selecting “New“as shown by the screen shot below
- The above action will result in the following screen being shown
- From here we can now add the paths we need. Note that this dependent on yourconfigurations. My variables are as follows;
- JAVA_HOME – C:\Program Files\Java\jdk1.7.0
- CATALINA_HOME – D:\tomcat (Note: I extracted Jakarta Tomcat to a folder in D and renamed it as jsut “Tomcat”)
- JAVA_HOME – C:\Program Files\Java\jdk1.7.0\lib,D:\tomcat\common\lib
Adding Apache Tomcat to Eclipse
Now that we have the above configured we can now test that Tomcat is working.Start your Eclipse and choose your workspace. We need to add Tomcat to Eclipse so that we can run it from Eclipse as opposed to starting it separetely. This is done as follows;
- In Eclipse go to “Window>Preferences” and then select the “Server” tab as shown in the screenshot below
- To add a new server instance select “Runtime Environments” and you will get a screen like the one shown in the screenshot below
- Click on the “Add” tab and then select the version of Tomcat you want to install as shown by the screenshot below
- Choose the version of Tomcat you have,for this tutorial I am using Tomcat 5.0.28 and so I chose v5.0 and then press next and you will get the screenshot below
- You then browse to the folder where you extracted Tomcat. However there is one more thing we need to do;we are not going to use the default JRE but rather the installed JDK so please click on the “Installed JREs” to add the JDK. You will get a screen like the one shown in the following screen shot
- Click on “Add” and you will get a screen similar to the one shown in the screenshot below
- Select “Standard VM” and then click on the “Next” button and you will be presented with a screen where you will specify the path to your JDK. The result of the selection should be as shown below;
- From there you just have to select the JDK as your JRE for Tomcat and follow the wizard until you are done. I skipped this part because it is fairly simple,if you face any problem,kindly let me know.
Testing Tomcat in Eclipse
To complete this second part of the tutorial we are just going to test whether the server is running. At the bottom of the Eclipse window is the pane that usually displays the console output. There is a tab for Servers,select the tab and you will see a screen similar to the screenshot below;
Click the start button to start the server and make sure you allow it to access both private and public networks.
That will be all for today,in the next tutorial we are going to create a simple J2ME application that allows a user to login into a system with the user details stored in a database.