Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need basic help to compile first servelet

 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll probably get better help with classpath and javac questions in the Java In General (Beginner) forum so.... moving.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Windows the separator used in the CLASSPATH is ; not :
 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joanne...I am able to compile it sucessfully without any doubts :-)..thnx a lot for clarifying
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic