[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: error starting java .jar app - classpath issue?



On Fri, Oct 28, 2005 at 12:09:42PM +0200, Andreas Pakulat wrote:
> On 27.10.05 20:55:41, Gordon Pedersen wrote:
> 
> > No errors if I switch to the .jar file directory and issue this
> > command:
> >         $ java -jar tt.jar
> 
> What else do you have in that directory?

Nothing else in the directory.

> > But if if try either of the following commands from another
> > directory, the errors shown below commands appear:
> > 
> >         $ java -jar /usr/share/java/tt.jar
> >         $ java -classpath /usr/share/java/tt.jar -jar /usr/share/java/tt.jar
> > 
> > Exception in thread "main" java.lang.NullPointerException
> >         at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
> 
> Hmm, if I'm correct, the constructor of ImageIcon is called with a
> relative path for the Image file, for example "example.gif". Now when
> you're not in the directory where example.gif lies, this might result in
> such an error. However, ImageIcon should probably check wether the file
> actually exists and not rely on it to be there...

It is possible that you're right.  Seems odd though in a product
several years old and probably in the hands of thousands (I
can't say), that everyone is habitually setting their working directory to
the app dir before invoking.  

> However: I did not check the source of ImageIcon and thus cannot say for
> sure what is "missing" at that point in the constructor...

I don't know how to check source on the official java library code.

> 
> > I wonder if it may just be a matter of learning how to correctly
> > set the CLASSPATH before issuing the java command on .jar
> > libraries held in /usr/share/java/. 
> 
> The problem is not the classpath, but the code in TimeTracker, it
> assumes that you run the jar-file from the directory where the images
> lie. That is, if my assumption about a file-not-found problem is
> correct.

Is there a way to find something out by inspecting the tt.jar file?

-- 
Gordon Pedersen             gordon@visi.com



Reply to: