Setting up Tomcat

Associate
Joined
8 Jan 2004
Posts
1,162
Location
CORNWALL
Trying to setup Tomcat on my XP machine.

Installed Java, Tomcat
Set 'Environment Variables'
  • C:\Program Files\Java\jdk1.6.0_10\bin
  • C:\Program Files\Java\Tomcat 6.0\lib\servlet-api.jar

created HelloWorld.java in webapps\webdir\WEB-INF\classes

run 'javac HelloWorld.java' in cmd (with in classes folder)

get following error
Code:
package javax.servlet.http does not exist
 
javax.servlet.http is an object that specifically exists within J2EE.

There are various "flavours" of Java, of which J2SE you seem to be working with. J2EE contains the stuff you need.

Take it from someone who has learnt the hard way to work with J2EE. That isn't a Tomcat issue.
 
J2EE isn't an API that you install like the JDK6.0, its an extension to the JDK. The servlet APIs should be included with tomcat, it should work out of the box. You don't "install J2EE", the correct classes should be bundled with your application server be it tomcat, JBOSS or glassfish. The only variable I remember having to setup to get tomcat to run stand alone was the JAVA_HOME env variable which had to point to a JDK (JRE is no good).
 
J2EE isn't an API that you install like the JDK6.0, its an extension to the JDK. The servlet APIs should be included with tomcat, it should work out of the box. You don't "install J2EE", the correct classes should be bundled with your application server.

Hmm fair enough. I personally (not through choice) use the JRun application server from Macromedia. Wasn't aware that Tomcat came with extra jars.

I had to download J2EE 1.3 (old java /sigh) to get our applications working in Eclipse and then link against the extended jars.
 
Edit: Yeah I totally mis-read, its not a tomcat config problem, its just that his servlet-api.jar isnt on his class path. He's trying to compile :/. My below still applies on setting up eclipse to do a web project though, it would automatically link the servlet-api.jar using the app server to let him compile.

--- My Original Post ---

When using eclipse they have a customised J2EE version of eclipse, but really it just supplies extra tools. In the J2EE version of eclipse you can create application servers using the run dialog (so basically you point eclipse at the location of your app servers), when you create a new dynamic web project using eclipse you also have to tell it what app server it will use and it will import the J2EE classes from your app server's folder, at least it's been that way for me.

--- Ignore all this because its not a tomcat config problem ---

I can't offer a solution to the OP because I'm a bit stumped because he seems to have the servlet-api.jar there. He's set up two useless environment variables though.

I could be wrong of course.

@OP

What version of tomcat, where did you download it from, are you running tomcat via the startup batch script or as a daemon?

P.S all that said I think that servlet-api.jar could just be interfaces, but certainly tomcat has to implement those interfaces concrete, I think that may be done in catalina.jar.
 
Last edited:
Back
Top Bottom