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

how to use the package structure . why can not find the package?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi, guys, I got a problem in try to take advantage of the java package structure. like this:
//------------
package a.b;
class One {
public int get(){return 8;}
}
//-----class Two try to use One
package a.c;
class Two{
public static void main(String ar[]){
int i = new a.b.One().get();
System.out.println(i);
}
}

and the directary is like : current/src (One.java and Two.java in this directary).
also exist current/classes

compile by useing the command like :
current : javac -d classes src/One.java
(works well and I get current/classes/a/b/One.class.)
current : javac -d classes src/Two.java
----------compile error, a.b.One package doesn't exist! ???
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
default access specifier is only limited to package ...
either you make your first class protected or public ... or take both classes in the same package ...
hope it help
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You posted this in another forum. PLEASE DO NOT POST A QUESTION IN MULTIPLE PLACES AS IT WASTES OUR TIME ANSWERING SOMETHING THAT'S ALREADY BEEN ANSWERED!!!

Thank you.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic