• 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

Access modifier doubt

 
Ranch Hand
Posts: 62
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 125
Postgres Database BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic