• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package not found problem  RSS feed

 
Eric Eichler
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writting some servlets for a class (that's class as in University class, not java class) but seem to be running into a problem. I have the following import statements:
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
I am using Eclipse with version j2sdk1.4.2_01. When I try to compile it says it cannot resolve the javax.servlet package. I'm pretty sure that the J2EE SDK has these packages, but when I try to install that, it wants to install everything (which I don't want to do). Is there a way to download only this package, install it, and add it to my classpath variable in Eclipse? I know how to add a variable to my Eclipse classpath, but I'm not sure on how to intall (or where to get) just this package. Thanks for any tips.
p.s. I posted this question over at forum.java.sun and someone said to download Tomcat. Well, I downloaded Tomcat but I can't seem to find anything in there to point my compiler to.
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you downloaded the tomcat , search for servlet.jar , that is what you need to run the servlets .Add that to your classpath.
Archana
 
Eric Eichler
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there isn't a servlets.jar file in the tomcat file i downloaded. i downloaded version 5.0.19 (jakarta-tomcat-5.0.19.zip). one other point, i don't want to run servlets on the machine i am compiling this on. all i want is to be able to compile them, but i don't have the javax.servlet package. can't i just download this package from sun or something like?
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually the required jar file comes with the servlet engine you are using.I think in tomcat 5 they chnaged the name to servletapi.jar.What is the servlet engine you are using, read the documentation for that , it should have the jar file.
 
Afroz Ahmed
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eichler,
Probably the servlet.jar or servletapi.jar file will be at <tomcat-dir>/lib directory.The <tomcat-dir> is the directory,where you had installed the tomcat.Set the jar file in your classpath and compile the servlet.
Regards
Afroz Ahmed
 
Eric Eichler
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I installed Tomcat 5 and it is running. I have a servlet-api.jar file in my "Tomcat 5.0\common\lib" directory. In Eclipse I click Window -> Preferences -> Java -> Classpath Variables. I click New, and in the boxes I have the name of the variable and the path is
C:/Program Files/Apache Software Foundation/Tomcat 5.0/common/lib/servlet-api.jar
My import statements still don't work. Thanks to everyone for their help thus far, but if you have any more suggestions they are appreciated.
 
Eric Eichler
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm somewhat embarrased but not really. I closed my project and then closed Eclipse. I clicked New -> Project and now there is an option for Tomcat project (as opposed to only Java project like before all this). Now, my servlet packages are resolved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!