Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javac cannot find servlet package

 
Patrick Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patrick, you need to set the CLASSPATH variable to the location of the Servlet.jar file.

You can also specify it during compilation as:
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably worth a look at our FAQ for servlets.
 
Patrick Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's it.
I thought that Java knows about Tomcat's jar files, but apperently not.
Regards, Patrick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic