How to make a shell script run on Mac by double-clicking on it?

I created a shell script to run the jar file on Mac:

#!/bin/sh java -Xmx512m -jar test.jar; 

I renamed this script " app.command " to run it directly when double-clicking on it. And I applied the chmod + x command to have executable permissions.

Now, when I double-click on this script icon, I get " Unable to access jarfile test.jar ", and when I run this script through the bank terminal it works fine!

Can anyone help me how to make this script run on double click on Mac?

+7
shell executable macos
source share
1 answer

If you start from the terminal, you have a working set of directories, and this may not be the case if you double-click it. Try specifying the full path to the jarfile in the script.

+8
source share

All Articles