[PLUG] Command line and paths

Rogan Creswick creswick at gmail.com
Wed Jan 30 08:24:01 UTC 2008


On Jan 30, 2008 12:00 AM, John Jason Jordan <johnxj at comcast.net> wrote:
> This evening I got an e-mail from the developer saying that he had figured out
> that to get the icons to appear you have to launch it from the command line
> while being in the folder where the .jar file is located. Thus, I need to:
>

This app is using relative paths to find the image files -- that is,
instead of looking for
"/home/jjj/Software/TreeForm102/buttons/button.jpg" it's looking for
"buttons/button.jpg" (for example).

The directory that you start the application from is the location that
these relative paths are resolved from, so if you launch treeform from
your home directory, it will look for images in
/home/jjj/buttons/button.jpg (following along with my fictional
example)

> cd ~/Software/TreeForm102
> java -jar TreeForm.jar

By changing directories you've changed the location that is used to
resolve relative paths, so now treeform is looking in the correct
place.

> But it's a lot easier to launch it from the Gnome panel application launcher. I
> had a launcher for it previously (which did not display the buttons), so I edited it
> so that the command line is "/home/jjj/Software/TreeForm102/java -jar
> TreeForm.jar." But after doing so it still launches without the buttons.

Generally, you can set the directory that an application runs from
when you create an application launcher, but when I just fired up
gnome-panel and tried it I didn't see anything related to this.  (I'll
try not to rant about gnome.)

As Kristian pointed out, you can also create a simple shell script
(say, Treeform.sh):

#!/bin/bash
cd ~/Software/TreeForm102
java -jar TreeForm.jar

make that executable:

chmod a+x Treeform.sh

and point your launcher at that.

> If I change to ~/ and launch it with this command it launches without the
> buttons:
> jjj at Devil7:~java -jar /home/jjj/Software/TreeForm102/TreeForm.jar

This doesn't change the directory you're *in* when you launch it -- it
just tells Java where to find the jar in excruciating detail.

--Rogan



More information about the PLUG mailing list