23

我有一个 Java .jar 应用程序,我想将它分发给我在 Mac 或 Windows 上的客户。我想使用一个工具来获取我的 jar 文件并将其分别包装在 Mac 和 Windows 的 .dmg 和 .exe 包装器中,在运行时执行此操作:

  1. 检查是否安装了 JRE;如果没有,它会从 Oracle 安装 JRE6。否则,它将安装的 JRE 更新到最新的 1.6.x 版本。
  2. 在开始菜单(在 Windows 中)或 Applications 文件夹(在 MacOSX 中)中创建一个指向我包装的应用程序的快捷链接,并让我的应用程序使用上述 JRE 运行
  3. 支持 Windows 的简单“卸载应用程序”。对于 Mac,只需将 .app 拖到废纸篓即可删除。

可选功能:

  1. 支持独立于平台的应用程序图标
  2. 支持自动更新jar
  3. 运行我的 .jar 时支持 JRE 的参数
  4. Linux 支持(.deb 或 .rpm)
4

6 回答 6

9

查看适用于 Mac的Package Maker和适用于 Windows 的Advanced Installer

我已经将它们用于您列出的几乎所有要求。

我没有将它们用于自动更新,但您可能必须将该逻辑构建到您的应用程序中。

不过,不要指望他们会为您完成所有工作。

预计会花费大量时间为每个平台构建安装程序。

我敢肯定 Windows 和 Linux 有很多选择。 Advanced Installer恰好是我唯一使用过的。

我相信Package Maker是 Mac 的标准。它非常棒且易于使用。

祝你好运!

于 2012-05-23T02:07:14.043 回答
1

For deploying on Windows, I like using Launch4j for wrapping my application jar and creating a native Windows executable that can detect and use an already installed JRE, or allows you to bundle your own. It's fast, lightweight and easily scripted with Ant (or Maven) as part of your build process.

Combined with this, I typically use NSIS for creating an installer that puts in shortcuts, and allows install/uninstall/repair from Control Panel. With a bit of work, this can also be scripted via Ant, and can also be built from a Linux platform.

These solutions obviously won't work for Mac deployment, but I suspect you'll have to use different tools for the different platforms if you want the best experience for the end users.

于 2012-06-26T02:38:38.850 回答
1

I have researched this for a while so that I can install the application in Linux and Windows. The best alternatives I found were -

You can find information how to use it native in this blogpost. But installing it in Linux got me to use a .sh script. As for mac my knowledge is limited. Hope this helps.

于 2012-06-26T05:35:57.850 回答
1

Note that if you develop your application as a netbeans platform application, then netbeans will produce cross platform installers for you (including for mac).

The fact that its a netbeans application has little impact on the look and feel of the app, you can still make it behave pretty much the same as any stand alone swing app.

This has the following advantages, which i think makes it a compelling option: - cross platform - its free - does not require a JDK to be installed prior to running the installer - integrates a software update process

于 2012-06-27T04:43:18.260 回答
1

There are already some good answers, but I guess JavaWebStart needs to be mentioned. Of course, it is only suitable for web deploment, but after installation Your application may also run offline.

The features (auto update, JVM version check, Desktop icon) are available.

Things to consider:

  • Your application needs to be singed to have access rights like a "normal" application.
  • afaik You cannot ship Your application on any other way than per web download.
于 2012-06-27T13:32:56.253 回答
1

Java Runtime Environment (JRE) is gone since JDK 11.

JDK 11 Release Notes states -

In this release, the JRE or Server JRE is no longer offered. Only the JDK is offered. Users can use jlink to create smaller custom runtimes.

u/0x256 on Reddit has a great comment regarding this issue:

There is no separate JRE anymore, only the JDK which includes all JRE parts (e.g. the java binary). Also, do not use OracleJDK unless you intend to pay them money. OpenJDK is the new default.

You can use jlink (which comes with the JDK) to distribute Java Apps. It will build a dedicated JRE for you. You do not need to have java installed on client machines.

An oracle blog article mentioned that -

Using the ‘jlink’ tool introduced with JDK 9 will make it even easier for application developers to package and deploy dedicated runtimes rather than relying on a pre-installed system JRE.

于 2019-04-16T13:09:38.537 回答