[PLUG] Java and bash

John Jason Jordan johnxj at comcast.net
Tue Aug 19 15:11:27 UTC 2014


On Tue, 19 Aug 2014 06:20:29 -0500
David Fleck <david.fleck at mchsi.com> dijo:

>On Mon, 2014-08-18 at 22:22 -0700, John Jason Jordan wrote:
>> At the moment I can launch it from the command line with java
>> -jar ./bookbinder3.0.jar. I created a launch menu item for it, but
>> the launcher fails with "unable to find program java." In other
>> words, it can't handle the spaces.
>
>Not sure what you mean here -- what spaces?

The two spaces in the command "java -jar bookbinder3.0.jar."

>> So I decided to create a bash script to launch it:
>> 
>> #!/bin/bash
>> /home/jjj/Software/bookbinder-3.0/java -jar ./bookbinder3.0.jar
>> 
>> I saved it and made it executable. But when I try to execute it
>> absolutely nothing happens. No error messages, nada. 
>
>What happens when you run
>/home/jjj/Software/bookbinder-3.0/java -jar ./bookbinder3.0.jar
>
>on the command line? Does it work then?

Yes, it runs fine.

>Do you actually have a java executable in
>the /home/jjj/Software/bookbinder-3.0 directory? That seems unlikely. 

No, 'which java' tells me that the java executable is in /usr/bin/,
but that location is in a path somewhere in the system so I don't have
to write out the path in order to run "java" on the command line.

>If I were making a first iteration on a script like this, I would
>probably do something like
>
>#!/bin/bash
>set -x
>/usr/bin/java -jar {full/path/to/bookbinder3.0.jar}

I rewrote the script so it says:

#!/bin/bash
set -x
/usr/bin/java -jar /home/jjj/Software/bookbinder-3.0/bookbinder3.0.jar

And now it works. Evidently I don't need the path to java from the
command line, but in a shell script I do need it. Thanks for the heads
up!



More information about the PLUG mailing list