| Author |
need basic help to compile first servelet
|
neetika sharma
Ranch Hand
Joined: May 19, 2006
Posts: 89
|
|
Hello, I have installed jakarta-tomcat-5.5.9 on Windows XP OS. I am following HFSJ for reference.While comiling the simple servlet as mentioned in chapter-3, i am getting loads of compilation errors as....... I have checked that servlet-jar file is present in proper path (c:/jakarta-tomcat-5.5.9/common/lib/servlet-api.jar) C:\Documents and Settings\neetika\Desktop\MyProject\beerV1>javac -classpath c:/jakarta-tomcat-5.5.9/common/lib/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:9: cannot find symbol symbol : class HttpServletRequest location: class com.example.web.BeerSelect public void doPost( HttpServletRequest request, HttpServletResponse resp onse) throws IOException, ServletException { ^ src/com/example/web/BeerSelect.java:9: cannot find symbol symbol : class HttpServletResponse location: class com.example.web.BeerSelect public void doPost( HttpServletRequest request, HttpServletResponse resp onse) throws IOException, ServletException { ^ src/com/example/web/BeerSelect.java:9: cannot find symbol symbol : class ServletException location: class com.example.web.BeerSelect public void doPost( HttpServletRequest request, HttpServletResponse resp onse) throws IOException, ServletException { ^ 6 errors How to compile this Please help. Big Thnx in advance
|
 |
neetika sharma
Ranch Hand
Joined: May 19, 2006
Posts: 89
|
|
If I set the classpath from cmd prompt as...... C:\Documents and Settings\neetika\Desktop\MyProject\beerV1>set CLASSPATH=.;C:\jakarta-tomcat-5.5.9\common\lib\servlet-api.jar and then simply giving C:\Documents and Settings\neetika\Desktop\MyProject\beerV1>javac src/com/example/web/BeerSelect.java then it is compiling.Can Anybody explain me this unexpected behaviour.Y is this not working with -classpath option during compilation.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
You'll probably get better help with classpath and javac questions in the Java In General (Beginner) forum so.... moving.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
|
On Windows the separator used in the CLASSPATH is ; not :
|
Joanne
|
 |
neetika sharma
Ranch Hand
Joined: May 19, 2006
Posts: 89
|
|
Originally posted by Joanne Neal: On Windows the separator used in the CLASSPATH is ; not :
I did not get , how this is related to my query. Do you want to say that whatever compilation errors I am getting is because of colon used??? But this is same as given in HFSJ. Kindly clarify
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
With your classpath as it is, the compiler is looking for a file or directory called c:/jakarta-tomcat-5.5.9/common/lib/servlet-api.jar:classes:. i.e. it thinks that it is a single file name because there are no separators If you change it to c:/jakarta-tomcat-5.5.9/common/lib/servlet-api.jar;classes;. then the compiler will look for a file called c:/jakarta-tomcat-5.5.9/common/lib/servlet-api.jar and will look for classes in the 'classes' directory and the current directory. The example in the HSFJ was probably written for use on Unix where the separator is a : [ June 09, 2006: Message edited by: Joanne Neal ]
|
 |
neetika sharma
Ranch Hand
Joined: May 19, 2006
Posts: 89
|
|
|
Thanks Joanne...I am able to compile it sucessfully without any doubts :-)..thnx a lot for clarifying
|
 |
 |
|
|
subject: need basic help to compile first servelet
|
|
|