Re: GIJ and paths and packages and the current directory
jmail@hursttechnical.com wrote:
Suppose my current directory is /A/B/C/Home, starting from the root of
the Linux filesystem.
Under Home, I have a subdirectory 'camera" that contains all my java
classes. When Home is my current directory, I can execute my java
application by typing:
gij camera.MyEntryPoint
This works fine. Gij finds the MyEntryPoint class, executes the main
method, and all the other classes in my application are found with no
problem as they are needed by the application.
Now, if I want to execute the same sort of command, but do it when the
Linux root directory is my current directory, I thought I should be
able to do the following:
gij --cp /A/B/C/Home camera.MyEntryPoint
Unfortunately, this starts the first class, but the first line in the
MyEntryPoint.class that refers to another class (which are all in the
same camera directory) throws a NullPointerException and says unknown
source. I believe this means that the gij program can't seem to find
the other classes in the camera directory, but I don't know why.
That's an unlikely reason for NullPointerException,
which means that you have tried to refer to an object via
a reference whose value is null. Classes that can't be
found when needed produce ClassNotFoundException (maybe
some others in unusual circumstances; I'm not sure), but
not NPE.
You *could* get NPE in a roundabout way, e.g., with
Class c = null;
try {
c = Class.forName("MissingClass");
} catch (ClassNotFoundException ex) {
// ignore (bad idea!)
}
Field f = c.getDeclaredField("name"); // possible NPE
.... but unless you're indulging in this sort of foolishness
I don't see how a missing class could produce an NPE. You
probably need to seek other causes; "missing class" is most
likely a red herring.
--
Eric Sosman
esosman@acm-dot-org.invalid