• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

head first servlets & jsp(example on pg 84,85)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the book for SCWCD (head first servlets & jsp)

in chapter 3 of the book on pg-84,85
the servlet version 2 is given and i have compilation problems with it

i have done all the necessary things

the servlet version 1 is running fine

i have this directory in windows vista

F:\project\Beer-v1\src\com\example\model (have BeerExpert.java)
and
F:\project\Beer-v1\src\com\example\web (have BeerSelect.java)

as given in the book
my classpath is also set fine and all the programs are running fine(servlets and other java programs)

but compilation problem is there for BeerSelect.java

when i do


F:\project\Beer-v1\src\com\example\web>javac -cp "c:\Program files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar" BeerSelect.java

following thing is shown

BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:19: cannot find symbol
symbol : class BeerExpert
location: class com.example.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:19: cannot find symbol
symbol : class BeerExpert
location: class com.example.BeerSelect
BeerExpert be = new BeerExpert();
^

3 errors
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sid, welcome to javaranch.

As per your question, I think that it should be in the SCWCD Forum.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think about what you learned in SCJP and ask yourself : is the "com" package in the classpath ?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the OP, I'm duplicating my answer here, as I originally posted in another thread which has now been locked:

======================================================================

From your other thread I see this is still a problem.

I had a minor issue when I tried it when first going through the book. What helped for me was:

1) Check you have the correct package names at the top of each java file!

2) Compile from the ROOT of the "application", not inside one of the src package sub-dirs that way the compiler can calculate the path to the other package i.e.

instead of:

F:\project\Beer-v1\src\com\example\web>javac -cp "c:\Program files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar" BeerSelect.java

try

F:\project\Beer-v1\javac -cp "c:\Program files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;classes" -d classes src\com\example\web\BeerSelect.java

the bits in bold are optional,[-d classes] I've added as per the book to write the class files to a different sub-directory, and tagged on ";classes" to the classpath so it includes the compiled package if targeting a different sub-dir. This assumes you have a F:\project\Beer-v1\classes subdirectory already.

HTH - Rufus.
 
sid dutta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
problem solved thanks my friends
 
reply
    Bookmark Topic Watch Topic
  • New Topic