• Post Reply Bookmark Topic Watch Topic
  • New Topic

package javax.servlet does not exist (for 2005 ;) )  RSS feed

 
Marvin Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searched for solution, lots of conflicting/old info, have been unable to implement solution.

1st ever Java install:
C:\j2sdk1.4.2_04

2nd addition:
C:\Program Files\Java\jre1.5.0

3rd addition:
C:\Program Files\Java\j2re1.4.2_07

Added these along the way while learning since Dec2003.

Per Tomcat 5.5 being optimized for JRE1.5.0, I accepted the default dir during Tomcat installation of:
C:\Program Files\Java\jre1.5.0

Tomcat starts up, all JSP/Servlet examples work fine.
When I open a command prompt, or use my free IDE(BlueJay)...get this error

When I'm at the command prompt, I have ALWAYS worked from:
C:\j2sdk1.4.2_04
to compile
ie;
C:\j2sdk1.4.2_04 javac HelloWorld.java

Will compile,and run programs in the same manner.


Again, there are many posts out there about a *.jar file needing to be here/there/etc.
However for Tomcat 5.5, I am totally ignorant of what to do, and if the settings truly go inside CLASSPATH or just PATH in winxp.

When setting up Tomcat, the instructions I had said just enter info into PATH, and it worked great - however since java needs access, I could understand if have to put something in CLASSPATH.

Thanks
 
Colin Fletcher
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java sojava

Welcome to the JavaRanch! Please adjust your displayed name to meet the

Naming Policy

You can change it

here.

Thanks! and welcome to the JavaRanch!
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a couple of JAR's that you have to add to the classpath that are contained in the Tomcat installation.

At minimum, the two that you will need will be called servlet-api.jar and jsp-api.jar. They are located in Tomcat's install directory under the common/lib directory.

There are a couple of methods of going about doing this depending on who you listen to:
1) Use the CLASSPATH environmental variable to add the JARs to the classpath. I am not particularly fond of this, but I don't know why...
2) Use the -cp tag on the javac command line to add the JARs to the classpath at compile time. I like this approach better. You can add the classpath arguments to a file so you don't have to re-write it all the time. This I like because you can use it to keep the classpath as small as possible by setting up several argfiles... see http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html#commandlineargfile for more
3) For your IDE, use whatever mechanism it has for defining the classpath...
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Luke:
At minimum, the two that you will need will be called servlet-api.jar and jsp-api.jar.


Okay, actually, at minimum is the servlet-api.jar. But the jsp-api.jar adds taglib classes and the like to your apps...
 
Marvin Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Steve

I actually was trying things similar to what you are stating, and unistalled, and installed v4 of Tomcat, and it seems to function.

Not sure what was causing it, but will go back later this week or next to try v5.0 again.

(was trying to figure this out from 9am-4pm) lol!

Thank you very much for taking the time!
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using ant to compile your classes...



Then, use this path in your classpath when compiling. That way, you know you're exposing everything that will be available to you at runtime by Tomcat.
 
Marvin Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanted to say thank you for taking the time to reply.

I do have ant installed, but have yet to use it, have this page on BOOKMARK

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!