*
The moose likes Beginning Java and the fly likes Why can't my class see another class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why can Watch "Why can New topic
Author

Why can't my class see another class?

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
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

Joined: Mar 14, 2001
Posts: 74
Please post the line of code with the import statement for the xxx.xxx.pch package.


"It is almost always answered in the API" - Murali Nanchala
Ken Cobbs
Greenhorn

Joined: Jun 18, 2002
Posts: 29
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

Joined: Feb 28, 2001
Posts: 455
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

Joined: Mar 14, 2001
Posts: 74
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

Joined: Feb 28, 2001
Posts: 455
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

Joined: Mar 14, 2001
Posts: 74
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
 
subject: Why can't my class see another class?