相当于 Mac 上可双击的 .sh 和 .bat?

发布于 2024-07-14 09:05:53 字数 225 浏览 5 评论 0原文

我正在分发一个 Java 程序,我希望在其中运行一个可双击的文件。

java -cp MyProgram.jar;MyLib.jar my.program.Main

在 Windows 上,我只需分发一个 .bat 文件,*nix 为一个可执行的 .sh 文件。 问题是,双击 .sh 文件只会在 Mac 上的文本编辑器中将其打开。 我应该为 Mac 做什么?

I am distributing a Java program where I want a double-clickable file to run

java -cp MyProgram.jar;MyLib.jar my.program.Main

On Windows I simply distribute a .bat file, for *nix an executable .sh file. Problem is, double-clicking the .sh file just opens it up in a text editor on Mac. What should I do for Mac?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

佞臣 2024-07-21 09:05:53

在 Mac 上,有一个通过双击执行 shell 脚本的特定扩展:这是 .command

On mac, there is a specific extension for executing shell scripts by double clicking them: this is .command.

岁月苍老的讽刺 2024-07-21 09:05:53

对于 Mac 上的 Java 应用程序,您确实应该使用 Apple 的 Jar Bundler(位于 Developer Tools/Applications/Utilities 文件夹中;实际上是到 /usr/share/java/Tools/Jar Bundler 的符号链接)。 它可以让您制作适当的 OS X 双击应用程序,包括设置首选项,例如使用 Mac 工具栏、JVM 版本、图形系统、OS X 应用程序元数据和类路径/资源。

For Java applications on Mac, you really should use Apple's Jar Bundler (in the Developer Tools/Applications/Utilities folder; really a symlink to /usr/share/java/Tools/Jar Bundler). It lets you make a proper OS X double-clickable app, including setting preferences for e.g. using the Mac toolbar, JVM version, graphics system, OS X app metadata and classpath/resources.

一个人的夜不怕黑 2024-07-21 09:05:53

您可以使用 .sh(Shell 脚本),毕竟 MacOSX 是 Unix!

You can use a .sh (Shell Script), after all MacOSX is Unix!

失退 2024-07-21 09:05:53

关于使用 Jar Bundler 工具的答案是正确的,但如果您想使用 .sh 文件,请确保将 unix 权限正确设置为带有 CHMOD 的 755 之类的内容,并确保第一行包含已安装 shell 的路径Mac OS X 上默认情况下。另请注意,即使设置了 +x 位,它仍然可能会询问用户是否要打开它或运行它。

The answer about using the Jar Bundler tool is correct, but if you want to use a .sh file, make sure the unix permissions are set properly to something like 755 with CHMOD, and make sure the first line contains the path to a shell installed by default on Mac OS X. Also note that even with the +x bit set, it may still ask the user whether they want to open it or run it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文