双击该脚本如何在Mac中运行? [英] How to make a shell script run in Mac when double clicking it?

查看:373
本文介绍了双击该脚本如何在Mac中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Shell脚本来在Mac中运行jar文件:

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

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

我已将该脚本重命名为" app.command ",以在双击该脚本时直接运行.而且我已对其应用" chmod + x "命令以具有可执行权限.

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.

现在,当双击该脚本时,我得到"无法访问jarfile test.jar ",而通过终端运行此脚本时,jar运行良好!

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 !

在Mac中双击该脚本,任何人都可以帮助我如何运行该脚本?

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

推荐答案

如果从终端运行,则必须设置一个工作目录,而双击该目录可能不是这种情况.尝试在脚本中提供jar文件的完整路径.

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.

这篇关于双击该脚本如何在Mac中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆