<xian_hong2046@hotmail.com> wrote...
> After I compiled PackageTest1.java and moved its .class
> into the proper directory, I tried to compile PackageTest2.java.
> The compiler's error message was:
>
> PackageTest2.java:5: cannot access PackageTest1
> bad class file: ./PackageTest1.java
There you got it!
It doesn't complain about PackageTest1.class, but on PackageTest1.java.
Move PackageTest1.java out of the classpath...
> If the compiler could find mytest.PackageTest1, then
> surely it should find mytest.*?
AFAIK, it works approximately this way:
When you explicitly declare PackageTest1 to belong to the package, it looks
there first, otherwise it looks through the whole classpath for
PackageTest1.class *AND* PackageTest1.java.
In that case (mytest.*) it isn't sure what package PackageTest1 belongs to,
and searches the whole classpath. Then it found a .java-file in the
*default* package and tries to work with that, but discovers that it defines
a class *not* belonging to the *default* package, hence a "bad class
file"...
// Bjorn A
xian_hong2046@hotmail.com - 19 Apr 2006 11:19 GMT
Thanks a lot! It worked after I moved .java out of the way! :)
xian