He all,
i have a problem with my bash script.
That’s my code:
#!/bin/bash
java -jar my_app.jar
echo "The present working directory is `pwd`"
If i exec it by ./script_name it work, but if i double click on it don’t work, i got this error:
“Unable to access jarfile my_app.jar”.
Then the pwd output is different !!!
My OS is MacOSX but i need to create a bash script that work in Linux too.
If you use a graphical tool to execute the script, the current working directory is arbitrary. The current working directory is not a useful concept in graphical applications, and they usually don’t use or change it. This means you must include the full path in the call to the
javaprogram, or change to the directory where the script is located. Unfortunately, there is no good solution for the latter.