Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in HFSJ chapter 3 Beer example

 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

This is kind of silly however i am not sure why i am getting an compile time error here...i am posting in this forum because the example i amdoing is from HFSJ chapter 3 BeerSelection...

while compiling BeerSelect.java i am getting the following error...

package import com.example.model does not exist

import com.example.model.*;

i have stored the BeerExpert.java file in com/example/model folder...and has been compiled and stored to com/example/model folder under classes folder.....

Have i missed some silly thing?

Please let me know if you need any more inputs...
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Atul,

What is this



package import com.example.model does not exist



it should be either package or import.
 
Balaji Londhe
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that your Web-inf is named so. Case matters.
Second thing you can check is if your class contains package statement at it's top.
 
Jeyalakshmi Palaniyandi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Atul Sawant,
i have also got the same error. use the following compilation options
javac -classpath classes;C:\tomcat\common\lib\servlet-api.jar -d classes src\com\example\web\your java file


this one is what we use for compilation
javac -classpath C:\tomcat\common\lib\servlet-api.jar -d classes src\com\example\web\your java file


see the difference
 
Jeyalakshmi Palaniyandi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think this will help to solve your problem
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying guys!

I had included the package name com.example.model in the BeerExpert and also imported the package as com.exaple.model.

command line as said above i had followed the same...

javac -classpath d:/tomcat/common/lib/servlet-api.jar -d classes src/com/example/web/BeerSelect.java

resulting.....

package com.example.model does not exist....

i am working on development environment right now...

please help.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone please?
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Atul,

What OS are you using?

I'm using Windows, and my compile String was:

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5"\common\lib\servlet-api.jar;classes -d classes src\com\example\web\BeerSelect.java

(My slashes seem to be the other way round to yours. Might help?).
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just ran the following and it all worked ok...

 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I think you have to add that class in classpath environment variables.
Like you must have added tools.jar in your classpath environment variable.
And thats why when you are importing all the java calsses like java.util,
java.math etc the system knows where to pick all thjese calsses. Like that yours is also an import statement and if I am not wrong you need to add this package path into your classpath system environment variable.

Just try this it may solve your problem.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am late at my own party!

Thanks guys...i will try all your answers. Priya Viswam emailed me a solution (such a nice lady!) Shamefully did not find time to try it out till now.

Thanks guys! you rock!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic