File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Javac cannot find servlet package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Javac cannot find servlet package" Watch "Javac cannot find servlet package" New topic
Author

Javac cannot find servlet package

Patrick Smith
Ranch Hand

Joined: Oct 08, 2007
Posts: 35
Hi,
when trying to compile my first web app, i get the error message displayed below.
I have Windows XPSP2 & JDK 1.5.0_16.
The JAVA_HOME is set to the JDK directory (without including the bin directory). No Classpath variable is set.
Thanks for your help, Patrick

>javac -d classes src/com/example/web/Beerselect.java
src/com/example/web/Beerselect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/Beerselect.java:4: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src/com/example/web/Beerselect.java:7: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
src/com/example/web/Beerselect.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse resp
onse)
^
src/com/example/web/Beerselect.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse resp
onse)
^
src/com/example/web/Beerselect.java:9: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {response.setContentType("t
ext/html");
^
6 errors
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
Patrick, you need to set the CLASSPATH variable to the location of the Servlet.jar file.

You can also specify it during compilation as:


SCJP 1.4 85%
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Probably worth a look at our FAQ for servlets.
Patrick Smith
Ranch Hand

Joined: Oct 08, 2007
Posts: 35
Thanks, that's it.
I thought that Java knows about Tomcat's jar files, but apperently not.
Regards, Patrick
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javac cannot find servlet package
 
Similar Threads
Unable to import
How To Compile Servlet
package does not exist problem
need basic help to compile first servelet
problem in compiling servlet