• 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

Why can't my class see another class?

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a class that is called Assembly.java.
It is located in the package com.storekraft.est.
Within this class is a reference to another class called Species.java.
The Species class is in the package com.storekraft.pch.
Within the Species class is a reference to another class called SpecieHistory.java
SpecieHistory.java is in the package com.storekraft.pch.
The Species class compiles. However, when I try to compile the Assembly class, it finds the Species class, but not the SpecieHistory class.
I have imported the com.storekraft.pch package into the Assembly class, but it still can't see it.
Could someone please tell me what I am doing wrong?
Thanks for any help!
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the line of code with the import statement for the xxx.xxx.pch package.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the "pecieHistory class" public or default?
A 'default' class can only be seen by class within the same package.
A class that's 'public' can be seen from other packages.
Just read that yesterday in Kathy and Berts Study Guide!
Hope it's what the trouble is
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was just playing aroung and tried something that worked.
Before, my import statement looked like this:

I changed it to read :

and it compiled.
Why wouldn't it compile with the original import statement if I told it to import all classes in that package?
Thanks!
 
Murali Nanchala
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How could you compile the Specie Class without compiling the SpecieHistory Class the first time? (Other than by using javac *.java).
Also, both forms of the import should work.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The SpecieHistory and Species classes compiled OK.
I just want to know why the Assembly class didn't compile with the import statement:

but did compile with the statements:
 
Murali Nanchala
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my code, and Assembly compiles after I compile the other classes, even with the package import instead of individual classes.
Species

SpecieHistory

Assembly
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic