Site Sponsors:
Installing Tomcat - Eclipse & Windows 

Step 1: Get Your JDK


Before doing "anything Java", we need to get the SDK.

While we are surely using JEE (Tomcat!), the plain old JDK is all that is required - indeed, because the JEE SDK + JDK packages install Glassfish as well, to the uninitiated, installing yet another web server can also compete for the same computer ports. It will drive beginners nuts!

So for this post, note that we are using JDK 6 Update 37. We got that here, not here. (Do YOU use Glassfish? -Neither does anyone else :)

Since the default port for Tomcat is 8080, you might want to be sure that http://localhost:8080/ is not being used...

Next, since the JDK will obviously have to RUN those things that we write, the JDK obviously includes the JRE. (If you do not know what a JRE or an JDK is, then please seek another page-of-worship. This post ain't where you want to be starting out ;-)

Install Your JDK


Since you will need to install the EXE (what we wanted to do on Windows), you will most likely need to be logged in as an Adminstrator.

So install your JDK, remembering where you install it: You will need to use that location in the next step. For my VM, the default was C:\Program Files\Java\....

Path Your JDK


Of course, just because we install something, does not mean that Apache / Tomcat will be able to find it. To allow others to find the Java that we want to use, we need to set up one of three (3) possible environment variables. Presently, these can either be PATH, JAVA_HOME, or the JRE_HOME.

Since the names imply what they are, we decided to use JAVA_HOME over the System-Wide PATH.

Env


Under Windows, Environment Variables are accessible via a RIGHT-click on Start | My Computer (or - since Microsoft, not those who bought it, owns it these days, post Windows XP it is just labelled "Computer" ;-) ) to peruse "Advanced Settings", then "Environment Variables."

Path


For the JAVA_HOME environment variable, we used C:\Program Files\Java\jdk1.6.0_37. If you used PATH, you would need to use C:\Program Files\Java\jdk1.6.0_37\bin.

Step 2: Get Your Tomcat


There are several ways to get a copy of Tomcat. Since we were using Eclipse Juno, after installing Eclipse, we just let the IDE download it for us. Others might want to download & unzip it from here.

No matter how (or where) we get Tomcat, the starting of it is simple: Unzip the install to a folder, open the folder, then go to the BIN directory. Thereafter, use the startup / shutdown commands to start & stop the Tomcat Server.

NOTE: Once Tomcat is running, that startup console window will remain open until Tomcat is shut down. If the console window flashes and then goes away, open another command prompt, navigate to that same folder, and run the startup file directly. 99 times our of 100, the output from the process will tell us that you need to repair your JAVA_HOME.

Once Tomcat is started, you can verify that all is well by navigating to port 8080 on your localhost. If Tomcat is running, then you will see a page displayed there.

Step 3: Get Your Server


Now open Eclipse. If you have a non-working Apache Server Definition installed in your Servers View, then delete the monster - config file and all.

To get a WORKING Server Definition:

(1) Out Of Eclipse: Start your Tomcat or otherwise verify that 8080 is showing that default Tomcat page. Do not run more than one instance of Tomcat.

(2) Inside Eclipse: Open a Server View to create a new Tomcat Server Definition. Map your installation path to wherever that presently-running instance of Tomcat is located.

(3) Test Your Server: Create a dynamic web project. Create an interesting index.html under that WebContent folder. Deploy and run the project on the Tomcat Server. All should be well!

(4) Out Of Eclipse: Once tested, Eclipse knows what to do from now on-out. It will deploy, run, shut-down, and test your web applications as expected. Feel free to shut Tomcat down.

Step 4: Notes


Note that if you want to use the Tomcat Manager Link on the default 8080 page, then we will have to include a user in Tomcat's config/tomcat-users.xml file:

If you are using Tomcat 6:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>


If you are using Tomcat 7:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role name="manager-gui"/>
<user username="admin" password="admin" roles="admin,manager-gui"/>
</tomcat-users>

Next, if you are using a NEWER version JRE in Eclipse (1.7), then when deploying to a web-based Tomcat, you might see:
java.lang.UnsupportedClassVersionError: 
com/javatunes/web/CartServlet :
Unsupported major.minor version 51.0 (unable to load class
com.javatunes.web.CartServlet)
The solution is to DOWNGRADE Eclipse to use a comparable JDK. (In this case, one would change your Eclipse Project from 1.7 to 1.6, so as to match (for example) the JAVA_HOME previously specified.)

Finally, if you still have a setup problem, then many find the `related link` (in red, below) to be of value - (I simply found most of it to be annoying :)

Cheers!

-Rn


[ add comment ] ( 2185 views )   |  permalink  |  related link

<<First <Back | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Next> Last>>