This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Java doesn't know where to find servlet packages

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading the headfirst servlets book and I'm trying to compile the first servlet in chapter 3, but Java is complaining that it can't find the servlet classes. Please help, so that I may continue taking over the world.
- John

C:\Documents and Settings\jm\My Documents\beerV1>javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\l
ib\servlet-api.jar:classes:." -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,
^
src\com\example\web\BeerSelect.java:9: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
HttpServletResponse response)
^
src\com\example\web\BeerSelect.java:10: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException{
^
6 errors
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to tell the compiler so by adding the path to yur servlet api classes to your classpath.
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by J Mangual:
C:\Documents and Settings\jm\My Documents\beerV1>javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\l
ib\servlet-api.jar:classes:." -d classes src\com\example\web\BeerSelect.java


Classpath entries should be separated by semi-colon ;
[ November 15, 2008: Message edited by: Vinod K Singh ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vinod K Singh:

Classpath entries should be separated by semi-colon ;



On Microsoft Windows, yes. On other systems, the colon he's used is correct.
 
J Mangual
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Semicolons (;) in Windows, huh... now it compiles.

Follow-up, there are three things I'm specifying in the classpath, servlet-api.jar, "classes" (not sure what that is) and "." which I guess means the current folder.

[edit]Disable smilies. CR[/edit]
[ November 17, 2008: Message edited by: Campbell Ritchie ]
 
Vinod K Singh
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:

On Microsoft Windows, yes. On other systems, the colon he's used is correct.


The directory structure in classpath seems to be from Windows thats why suggested for semi colon.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic