gpt4 book ai didi

适用于 Mac 的 Java 应用程序

转载 作者:行者123 更新时间:2023-12-02 01:37:49 25 4
gpt4 key购买 nike

我以前从未使用过 mac,所以我有一个关于在 mac 上运行 java 应用程序的最佳方式的问题,因为我在网上没有找到很好的答案。

所以我构建了一个 java 应用程序,并且必须将其发送到使用 mac 的客户端。我知道您可以在 mac 上使用 java -jar app.jar 从终端运行 .jar,但我想要一个客户端只能单击并可双击的图标启动程序。

我看过一些教程,其中有人制作了一个 .jar 文件,您只需双击该文件,程序就会在 macos 中启动,所以我不确定您是否可以运行 .jar 在 Macos 中只需双击即可执行?

我看到的另一个解决方案是制作一个简单的 .command 文件,该文件将使用 java -jar app.jar 运行应用程序。所以我想知道从 .jar 文件制作 mac 可执行文件的最佳方法是什么?

最佳答案

你的问题不错。

答案是“视情况而定”。 “最佳解决方案”完全有可能是简单地发送 .jar 文件以及调用它的说明。

请查看Oracle文档:

Java Documentation Section 7: Self-Contained Application Packaging

7.1 Introduction

The Java packaging tools provide built-in support for several formats of self-contained application packages. The basic package is a single folder on your hard drive that includes all application resources and the JRE. The package can be redistributed as is, or you can build an installable package (for example, EXE or DMG format.)

From the standpoint of process, producing a self-contained application package is similar to producing a basic application package as discussed in Chapter 5, "Packaging Basics," with the following differences:

Self-contained application packages must be explicitly requested by passing additional arguments to the Ant task or javapackager tool.

Operating system and tool requirements must be met to be able to build a package in a specific format.

Self-contained application packages can only be built using JDK 7 Update 6 or later.

While it is easy to create a basic self-contained application package, tailoring it to achieve the best user experience for a particular distribution method usually requires some effort and a deeper understanding of the topic.

...

7.3.5.1 OS X

The resulting package on OS X is an "application bundle".

Several configuration parameters are placed in the Info.plist file in the application bundle and must conform to the following rules:

Application ID (or main class name if ID is not specified) is used as CFBundleIdentifier.

Application version is used as CFBundleShortVersionString.

OS X 10.8 引入了 Gatekeeper,可防止执行不受信任的操作 默认代码,无论该代码是否实现于 Objective-C 或 Java。

用户可以手动启用应用程序运行,但这不是一个 完美的用户体验。为了获得最佳的用户体验,请获取 Apple 的开发者 ID 证书。 Mac 捆绑程序使用 用于签署 .app 文件夹的证书。如果您的本地用户信息 与证书的名称不同,您可能需要设置 捆绑参数 mac.signing-key-user-name,如下所示 示例:

关于适用于 Mac 的 Java 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54966656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com