Ed Severn wrote:
Raymond,
Yes, I was sloppy there. I meant that "def.java" uses class "ghi", say, but
"ghi.java" does not have a "package" statement. So "ghi" belongs to the
"anonymous" package (which is probably the wrong term to use).
I think the proper term is the "default" package.
Perhaps the answer to my question is that when I compile def.java (which has
a "package p.q.r;" statement), then the compiler expects that "ghi" belongs
to that same package "p.q.r", and the compiler looks for "ghi.class" in the
p/q/r directory.
If this is the case, then how can "def.java" make use of a class (namely
"ghi") which does not belong to any named package?
Well, you could be out of luck. I remember seeing a bug report on Sun
that seemed to be in this area; I think they made it so you can't import
a class from the default package (i.e., using an import directive).
Assuming that you are not out of luck, this is how I would approach the
problem. First, compile ghi.java to generate ghi.class and place it in
a directory called classes (for example). Make sure that the classes
directory is in the classpath when you compile def.java.
If this does not work, I would consider rewriting ghi.java so that it
belongs to a package and then can be imported in def.java. If you do
not have the source code for ghi.java, you might consider decompiling
it, assuming that the license under which you obtained it allows that,
or asking the library provider to provide a usable library.
(Another possibility is moving def.java into the default package, but
that is really moving in the wrong direction.)
HTH,
Ray
--
XML is the programmer's duct tape.