Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Packages from Kathy Sierra Book

 
Emad Salahuddin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is in regards to pg 63 of Kathy Sierra Book.
I have created a class Beverage in package cert.
package cert;
class Beverage {}
I have class Tea that extends class Beverage in exam.stuff package.
package exam.stuff;
import cert.Beverage;
class Tea extends Beverage{}
Both packages are in my D:\ drive.
The problem is that I don't get the following error: Tea.java:1: Can't access class cert.Beverage....(As stated in the book)
Instead I get the following:
Tea.java:3: package cert does not exist
import cert.*;
^
Tea.java:5: cannot resolve symbol
symbol : class Beverage
location: class exam.stuff.Tea
class Tea extends Beverage{}
^
2 errors
What is it that I am doing wrong? Even when I make the Beverage class public I get the same errors.
When both classes are in the same package they compile fine.
Any help will be greatly appreciated.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Emad
please see if u follow the steps i would follow if i were u...
1. make sure i have,
- d:\cert\Beverage.java
- d:\exam\stuff\Tea.java
2. i go to ,
d:
3. make sure i have "." (current directory) in the CLASSPATH env variable. if u don't have it u can compile like following step...
4. javac -classpath %CLASSPATH%;. cert\*.java
5. javac -classpath %CLASSPATH%;. exam\stuff\*.java
can u try that and let us know if u face more problems?
regards
maulin
 
Emad Salahuddin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Maulin.
Thanks for your help. I used your steps 4 and 5 to compile and it worked.
Thanks Again
Emad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic