• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Javac cannot find servlet package

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Marshal
Posts: 75719
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, that's it.
I thought that Java knows about Tomcat's jar files, but apperently not.
Regards, Patrick
 
Don't MAKE me come back there with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic