Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Java
  • » error starting java .jar app - classpath issue? [RSS Feed]

#1 Oct. 28, 2005 02:55:49

Gordon P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

error starting java .jar app - classpath issue?


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.

This is likely a very simple issue. I've never tried to run a
java .jar library on debian before.

For all commands discussed below, no CLASSPATH environment
variable has been defined.

No errors if I switch to the .jar file directory and issue this
command:

$ java -jar tt.jar

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)
at
com.taubler.timebox.submit.SubmitExtensionWidget.<init>(SubmitExtensionWidget.java:16)
at
com.taubler.timebox.submit.SubmitManager.<init>(SubmitManager.java:52)
at com.taubler.timebox.TimeTracker.<init>(TimeTracker.java:54)
at com.taubler.timebox.TimeTracker.main(TimeTracker.java:1115)

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/. I could not find any
clear guidance about the usual CLASSPATH practice on debian.

(I run sarge. Java is from blackdown j2re1.4 and j2sdk1.4.
Installed without a hitch.)

(App in question is a timekeeper program. Seehttp://www.taubler.com/timebox/.)

Thanks.


--
Gordon Pedersen
St Paul, Minnesota, USA


--
To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Offline

#2 Oct. 28, 2005 11:09:43

Andreas P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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.

Offline

#3 Oct. 28, 2005 14:01:47

Gordon P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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


--
To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Offline

#4 Oct. 28, 2005 15:15:37

Andreas P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

error starting java .jar app - classpath issue?


On 28.10.05 08:01:40, Gordon Pedersen wrote:
> On Fri, Oct 28, 2005 at 12:09:42PM +0200, Andreas Pakulat wrote:
> > On 27.10.05 20:55:41, Gordon Pedersen wrote:
> > 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.

Well, if you use that thing on windows what you typically do is
double-click onto the file -> working dir is app dir. On linux the
situation might be similar, or do you want to always type a long path?
;-)

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

Sun's jdk has the source for most classes in the src.zip file. For free
implementations you should be able to do a apt-get source <java-package>

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

Is that thing not available as source code? If not: There are ways to
get to the source code from the byte-code, however I think that might be
illegal depending on the license of the program.

Andreas

--
You plan things that you do not even attempt because of your extreme caution.


--
To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Offline

#5 Oct. 29, 2005 19:01:42

Gordon P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

error starting java .jar app - classpath issue?


On Sat, Oct 29, 2005 at 01:08:47AM +0200, Andreas Pakulat wrote:
> On 28.10.05 16:39:27, Gordon Pedersen wrote:
> > On Fri, Oct 28, 2005 at 04:10:32PM +0200, Andreas Pakulat wrote:
> > > On 28.10.05 08:01:40, Gordon Pedersen wrote:

> > I'd assumed that on linux with java apps, one can execute them
> > by giving the correct paramaters including the complete pathname
> > of the .jar app file.
>
> You might do it that way, the users should only have to specify a
> command that does all that (i.e. a shell script lying in /usr/bin and
> executing java -jar /path/to/jar -option1 -option2)..

I ended up making a little script that needs to be something
like this:
$ cd /var/opt/timebox
$ java -jar tt.jar

But it does rankle, this java .jar that insists on BOTH being
invoked from the very directory where it resides, AND writing to
that very directory. I don't know debian policy very well, but
it seems to me both policy-flouting and somewhat insecure. If I
knew there was a potential security hole, I'd file a bug
with the author (who probably could care less about debian
policy).

> Then this application cannot be installed that way in a system-wide
> location. For that application to be properly packaged you propably need
> to fix the source so that it doesn't try to write in arbitrary locations
> and loads it's images either from within the jar (via Resources) or from
> a fixed, proper location in the system (i.e.
> /usr/share/<yourapp>/icons).

Good to know. Still don't know enough to make a case to
the app developer, but you've helped clarify things.

Along the way stumbled onto JPackage. And found an applicable
article: <a href="http://www.linuxbase.org/LSBWiki/LsbJava";>
Linux Standard Base RFP</a> for java mdoules, base libraries,
executables


> hack-around by installing this thing into /usr/share/<yourapp>,
> modifying the access rights on that directory to give a group
> "<yourapp>" write acces and then everybody who wants to run the app has
> to add himself to that group. This would be addressed in the
> README.Debian and you should probably add a shell script to the package

Thanks.

--
Gordon Pedersen


--
To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Offline

  • Root
  • » Java
  • » error starting java .jar app - classpath issue? [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support