macos 在 Mac 上将 jar 文件作为应用程序启动(从 Dock)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8916269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:47:00  来源:igfitidea点击:

Launching a jar file as an app on Mac (from the dock)

macosjar

提问by whwright

I have an application packaged as a jar file on my mac. I wish to launch this app from the dock as if it is a .app file. Is there a way to do this?

我的 mac 上有一个打包为 jar 文件的应用程序。我希望从 Dock 启动这个应用程序,就像它是一个 .app 文件一样。有没有办法做到这一点?

回答by piersadrian

Sure. JAR files can be launched just like .apps can. Just drag the JAR to the section of your Dock closest to the trash can (it won't work in the main section of your Dock, as that area is reserved for .apps), on the other side of the little separator. Keep in mind that Lion (OS X 10.7) doesn't come with Java pre-loaded, so you may have to download the Java Runtime Environment(JRE) to run JARs.

当然。JAR 文件可以像.apps一样启动。只需将 JAR 拖到 Dock 最靠近垃圾桶的部分(它不会在 Dock 的主要部分工作,因为该区域是为.apps保留的),位于小分隔符的另一侧。请记住,Lion (OS X 10.7) 未预加载 Java,因此您可能必须下载 Java 运行时环境(JRE) 才能运行 JAR。

(Also, this question is much better asked over on Ask Different, the Apple Stack Exchange site.)

(此外,在 Apple Stack Exchange 网站Ask Different询问这个问题要好得多。)

回答by user828878

You can create a workflow with Automator, add a 'Run Shell Script' step and save it as an application. Something like this:

您可以使用 Automator 创建工作流,添加“运行 Shell 脚本”步骤并将其另存为应用程序。像这样的东西:

java -jar /path/to/your/file.jar

You can then just pull it into your doc (and give it an icon if you like)

然后你可以把它拉到你的文档中(如果你愿意,可以给它一个图标)

回答by Xiaogang

Yes, you should let the file closest to the trash. Otherwise, it could not be attached in the dock.

是的,您应该让文件最靠近垃圾箱。否则,它无法连接到扩展坞中。