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

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



On 27.10.05 20:55:41, Gordon Pedersen wrote:
> I'm reluctant to post to a developers list, but this question
> got no help at debian-user in the past 2 days.  It seems to be
> debian-related more than generic java-related.

It's not even really java-related, the same can happen with any
programming language.

> 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?

> 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...

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 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.

Andreas

-- 
Change your thoughts and you change your world.



Reply to: