Reputation: 11
I create a new user library named reference and I add a JAR file called stdlib to this library. Then I creat two classes. Class A with main method is in the default package. Class B is in other package. It's OK to use methods in reference library in Class A. For example, StdOut.println(); However, the program cannot recognize it when I use it in Class B, which is in another package.
Then I built a new class C in the default package. the reference library works fine in Class C. Can anyone tell me what's wrong with my program? Why can't I use methods from reference library in Class B, which is not in the default package? Thx!
Upvotes: 1
Views: 117
Reputation: 1502626
I suspect you're just missing an import:
import foo.bar.ClassB;
where foo.bar
is the package containing ClassB
.
(As an aside, I'd strongly advise against using the default package in your own code.)
Upvotes: 2