JAR 安装程序会自动检测 Java 是否存在并自动启动应用程序

发布于 2024-07-23 11:59:14 字数 203 浏览 8 评论 0原文

我需要构建一个执行以下操作的安装程序:

  1. 在客户端上安装我的 jar。
  2. 自动检测 JRE 是否已安装(在这种情况下,不会重新安装),否则无需用户单击其他按钮即可安装。
  3. 客户端启动时自动启动应用程序。
  4. 适用于 Windows、Mac 和 Linux。

知道如何去做吗?

I need to build an installer that does the following:

  1. Installs my jar on the client.
  2. Auto-detects if JRE is installed (in which case it does not re-install it), otherwise installs it without the user clicking on another button.
  3. Auto-starts the application when the client is booted.
  4. Works across Windows, Mac and Linux.

Any idea how to go about it?

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

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

发布评论

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

评论(6

时常饿 2024-07-30 11:59:14

如果商业工具没问题,我可以推荐 install4j。 1、2和4很容易做到,但3我不确定。 编辑:您可以通过将应用程序安装为“服务”来实现这一点,install4j 支持所有平台。 引用其功能页面:

install4j 提供全面支持
生成和安装服务
(守护进程)。 对于服务,安装4j
生成服务可执行文件
Windows、Mac OS X 上的启动项和
Unix/Linux 上的启动/停止脚本
平台。

编辑:关于#2,JRE 检测:install4 为 JRE 捆绑/检测提供了非常漂亮、灵活的选项。 您可以包含 JRE(静态或动态、共享或不共享),或者更喜欢使用已有的 JRE,并且可以从安装程序中下载 JRE 作为后备。 检查这些文档以了解更多信息:安装人员如何查找 JREJRE 捆绑包

更多关于我的经验install4j。)

对于其他工具,您可以检查一些早期的 Java 安装程序 问题:

If a commercial tool is ok, I can recommend install4j. 1, 2 and 4 are easy to do with it, but about 3 I'm not sure. Edit: You could probably achieve that by installing your app as a "service", which install4j supports for all platforms. Quoting from its Features page:

install4j offers full support for
generating and installing services
(daemons). For services, install4j
generates service executables on
Windows, startup items on Mac OS X and
start/stop scripts on Unix/Linux
platforms.

Edit: Regarding #2, JRE detection: install4 has pretty nice, flexible options for JRE bundling/detecting. You can include a JRE (statically or dynamically, shared or not) or prefer to use one already present, with the possibility to download a JRE from within your installer as a fallback. Check these docs for more: How Installers Find a JRE and JRE Bundles.

(More about my experiences with install4j.)

For other tools, you could check some of the earlier Java installer questions on SO:

爱你是孤单的心事 2024-07-30 11:59:14

InstallAnywhere 等商业工具可以做到这一点。 安装 JAR(以及链接等)后,安装程序可以检查注册表是否已安装 Java 并继续或不继续。 只要安装程序支持所有需要的平台,就可以了。

Commercial tools like InstallAnywhere can do that. After installing the JAR (and links and such), installers can check the registry if Java is already installed and proceed or not. As long as the installer supports all needed plattforms, you are fine.

旧故 2024-07-30 11:59:14

您可以使用 launch4j ,但是它不会自动安装java。 但也许有一种方法可以通过打包 JRE 来实现这一点。

You could use launch4j , it does not automatically install java however. But maybe there's a way to make that work by packaging the JRE for example.

冰雪梦之恋 2024-07-30 11:59:14

您可能还想看看 BitRock InstallBuilder,它提供了内置功能来执行您想要的操作。 我们很乐意为您构建示例安装程序,请给我们留言。

You may also want to take a look at BitRock InstallBuilder, it provides built-in functionality to perform what you want. We will be happy to build a sample installer for you, just drop us a line.

不打扰别人 2024-07-30 11:59:14

我建议下载流行 Java 程序(如 Limewire)的构建脚本的源代码并遵循他们的示例。 结束。

...或者你可以像我一样:

  • 我已经完成了 JRE 检测并且
    如果需要的话,下载/安装可再发行版本
    Windows 上的 NSIS。 也许 .msi 比 NSIS 创建的 installer.exe 更好。 我相信 msi 更像是 mac 上的软件包,因此它们允许正确的更新。 也许 NSIS 创建了 MSI...不确定。
  • Mac 只是一个 Java 应用程序
    捆绑并指定 JRE 和其他 Java 信息
    info.plist,您可以选择创建一个 .pkg
    文件为用户提供安装程序并使用命令行 dmg 程序捆绑在 dmg 中。
  • 我还没有做过 Linux,也不打算这么做……抱歉:)

所有这些都是相当大的工作量。 我首先做了 Windows 的东西,几年后又做了 Mac 的东西。

您可以将所有这些集成到 NSIS 构建脚本和 Ant 中。 我不记得为什么我没有使用 install4j。 可能是我太便宜了:)

I recommend downloading the source code for the build scripts of popular Java programs like limewire and follow their example. The end.

...Or you can do like I did:

  • I have done the JRE detection and
    download/install of redistributable if required with
    NSIS on Windows. Maybe an .msi is better than a installer.exe which NSIS creates. I believe msi are more like packages on mac so they allow proper updates. Maybe NSIS creates MSIs... not sure.
  • Mac is simply an Java App
    bundle and you specify the JRE and other Java info in the
    info.plist and you can optionally create a .pkg
    file to give the user an installer and bundle up in a dmg using the command line dmg programs.
  • I haven't done Linux and don't plan to... sorry :)

All this was a fair chunk of work. I first did the Windows stuff then a couple years later did the Mac stuff.

You can integrate all of this in NSIS build scripts and Ant. I can't remember why I didn't use install4j. Probably I was too cheap :)

烦人精 2024-07-30 11:59:14

还没有听说过任何可以跨所有这些平台工作的东西,但是 JSmooth 可能会有所帮助(满足您在 Windows 上的需求)。 我大约 2 年前就用过它,效果很好。

Haven't heard of anything that works across all those platforms, but JSmooth might help (fits your needs on Windows). I've used it about 2 years ago and it worked fine.

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