Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

need basic help to compile first servelet

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Joanne...I am able to compile it sucessfully without any doubts :-)..thnx a lot for clarifying
 
reply
    Bookmark Topic Watch Topic
  • New Topic