JAR 安装程序会自动检测 Java 是否存在并自动启动应用程序
我需要构建一个执行以下操作的安装程序:
- 在客户端上安装我的 jar。
- 自动检测 JRE 是否已安装(在这种情况下,不会重新安装),否则无需用户单击其他按钮即可安装。
- 客户端启动时自动启动应用程序。
- 适用于 Windows、Mac 和 Linux。
知道如何去做吗?
I need to build an installer that does the following:
- Installs my jar on the client.
- 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.
- Auto-starts the application when the client is booted.
- Works across Windows, Mac and Linux.
Any idea how to go about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果商业工具没问题,我可以推荐 install4j。 1、2和4很容易做到,但3我不确定。 编辑:您可以通过将应用程序安装为“服务”来实现这一点,install4j 支持所有平台。 引用其功能页面:
编辑:关于#2,JRE 检测:install4 为 JRE 捆绑/检测提供了非常漂亮、灵活的选项。 您可以包含 JRE(静态或动态、共享或不共享),或者更喜欢使用已有的 JRE,并且可以从安装程序中下载 JRE 作为后备。 检查这些文档以了解更多信息:安装人员如何查找 JRE 和 JRE 捆绑包。
(更多关于我的经验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:
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:
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.
您可以使用 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.
您可能还想看看 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.
我建议下载流行 Java 程序(如 Limewire)的构建脚本的源代码并遵循他们的示例。 结束。
...或者你可以像我一样:
如果需要的话,下载/安装可再发行版本
Windows 上的 NSIS。 也许 .msi 比 NSIS 创建的 installer.exe 更好。 我相信 msi 更像是 mac 上的软件包,因此它们允许正确的更新。 也许 NSIS 创建了 MSI...不确定。
捆绑并指定 JRE 和其他 Java 信息
info.plist,您可以选择创建一个 .pkg
文件为用户提供安装程序并使用命令行 dmg 程序捆绑在 dmg 中。
所有这些都是相当大的工作量。 我首先做了 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:
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.
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.
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 :)
还没有听说过任何可以跨所有这些平台工作的东西,但是 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.