• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access modifier doubt

 
Prashanth Patha
Ranch Hand
Posts: 62
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created one source file named 'Beverage.java' as follows :

// Beverage.java

class Beverage // default access and is in the current working directory(package)
{

}

It compiled fine.

But ,

// Tea.java

class Tea extends Beverage // also default access and is in the current working directory(package)
{
}

When this Tea.java file is compiled , it is giving an error that " Cannot find class Beverage " . Why it is so , even they are in same package(current default package).
 
Achilleas Achix
Ranch Hand
Posts: 123
BSD Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
two quick ones:

1) your classes DO NOT BELONG TO ANY PACKAGE, there is no "package" designation in your sources
2) they should compile ok. check CLASSPATH env variable, if not set or not there, ensure it contains the "." directory.
 
Prashanth Patha
Ranch Hand
Posts: 62
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Achilleas Achix wrote:two quick ones:

1) your classes DO NOT BELONG TO ANY PACKAGE, there is no "package" designation in your sources
2) they should compile ok. check CLASSPATH env variable, if not set or not there, ensure it contains the "." directory.

Thank you.....

I got it resolved by ensuring CLASSPATH include "." directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic