File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why can't my class see another class?

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Murali Nanchala
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the line of code with the import statement for the xxx.xxx.pch package.
 
Ken Cobbs
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic