Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

package javax.servlet does not exist

807601Jan 16 2008 — edited Jan 20 2008
i know that this problem is posted all over the web, however none of the solutions seem to work for me. I am running jdk1.6.0_03 in eclipse. When I try to do an ant build on one of my projects, I receive about 6 errors, and the build fails.

Buildfile: C:\Program Files\eclipse\workspace\My Project\build.xml
check-properties:
deploy:
compile:
[javac] Compiling 6 source files to C:\Program Files\eclipse\workspace\My Project\examples-library\target\classes
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\BannerService.java:11: package javax.servlet does not exist
[javac] import javax.servlet.ServletException;
[javac] ^
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\BannerService.java:44: cannot find symbol
[javac] symbol : class ServletException
[javac] location: class bannerads.library.BannerService
[javac] throws ServletException, IOException
[javac] ^
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\impl\XMLBannerSource.java:17: package javax.servlet does not exist
[javac] import javax.servlet.ServletContext;
[javac] ^
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\BannerService.java:28: cannot access javax.servlet.ServletException
[javac] class file for javax.servlet.ServletException not found
[javac] public class BannerService extends AbstractService
[javac] ^
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\impl\XMLBannerSource.java:83: cannot find symbol
[javac] symbol : class ServletContext
[javac] location: class bannerads.library.impl.XMLBannerSource
[javac] ServletContext servletContext =
[javac] ^
[javac] C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\impl\XMLBannerSource.java:84: cannot access javax.servlet.http.HttpServlet
[javac] class file for javax.servlet.http.HttpServlet not found
[javac] cycle.getRequestContext().getServlet().getServletContext();
[javac] ^
[javac] Note: C:\Program Files\eclipse\workspace\My Project\examples-library\src\java\bannerads\library\impl\XMLBannerSource.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 6 errors

BUILD FAILED
C:\Program Files\eclipse\workspace\My Project\build.xml:23: The following error occurred while executing this line:
C:\Program Files\eclipse\workspace\My Project\examples-library\build.xml:40: Compile failed; see the compiler error output for details.

Total time: 3 seconds

Here are my environment variables:

my ANT_HOME variable is

C:\Program Files\apache-ant-1.7.0

my CLASSPATH variable is

.;C:\Program Files\apache-tomcat-6.0.14\lib\servlet-api.jar;

My JAVA_HOME variable is

C:\Program Files\Java\jdk1.6.0_03

and i added the following values to my PATH variable

%ANT_HOME%/bin;%JAVA_HOME%/bin;

Any help with this would be greatly appreciated, thank you! Also, I did try adding servlet-api.jar to my build path properties of the project in eclipse. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2008
Added on Jan 16 2008
9 comments
2,497 views