How to make a shell script run in Mac when double clicking it?

人盡茶涼 提交于 2019-12-21 11:45:12

问题


I have created a shell script to run a jar file in Mac :

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

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

Now when double clicking this script, i get "Unable to access jarfile test.jar" while when running this script through Terminal, the jar runs fine !

Anyone can help me how to make this script run when double click it in Mac ?


回答1:


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.



来源:https://stackoverflow.com/questions/4043573/how-to-make-a-shell-script-run-in-mac-when-double-clicking-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!