+3  A: 

If you run from a terminal, you have a working directory set, and this may not be the case if you double-click it. Try giving the full path to the jarfile in your script.

Curtis
@Curtis: You are right. But is there a way to overcome this ? The jar can be anywhere, but i am sure the shell script will be in the same folder of the jar file ?
Brad
Not sure. My macs are all at home, and I can't get to them. I know in Windows, there's a way to set the working directory when you create the shortcut to an application. Maybe there's something similar on the Mac? You might have to create a shortcut that runs your script, rather than double-clicking the script directly.
Curtis
Brad
This can get arbitrarily complicated, but if the script is run by double-clicking (and isn't a symbolic link), `cd "$(dirname "$0")"` should work.
Gordon Davisson
@Gordon ... Thanks a lot .. So how would i use this in my script ? :) ... I know nothing about shell scripting. Example please ?
Brad
Add this command as the second line of the script (i.e. right after `#!/bin/sh` -- that way the rest of the script (mainly the `java` command) will execute from within the script's directory.
Gordon Davisson
@Gordon ... Thanks a lot ... Works perfect.
Brad