| Author |
Java doesn't know where to find servlet packages
|
J Mangual
Greenhorn
Joined: Nov 15, 2008
Posts: 16
|
|
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
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
You need to tell the compiler so by adding the path to yur servlet api classes to your classpath.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Vinod K Singh
Ranch Hand
Joined: Sep 30, 2008
Posts: 198
|
|
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 ]
|
My Blog
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
J Mangual
Greenhorn
Joined: Nov 15, 2008
Posts: 16
|
|
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
Joined: Sep 30, 2008
Posts: 198
|
|
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.
|
 |
 |
|
|
subject: Java doesn't know where to find servlet packages
|
|
|