Launch4J 和 Java Web Start 的结合?

发布于 2024-09-12 11:24:04 字数 1222 浏览 5 评论 0原文

我有一个正在运行的 JNLP 应用程序,我需要将其分发给各种非技术最终用户。

如果用户的机器最近安装了 JVM,那么一切都很好。他们只需双击我发送给他们的 JNLP 文件,Java Web Start 就会完成剩下的工作。

现在我想分发一些可以使用或不使用 JVM 的东西,例如 .exe 文件,如果没有兼容的 JVM,它会自动下载,然后调用 javaws.exe > 下载 .jar 文件并启动应用程序。

Launch4J 是我找到的最接近的匹配,但它无法通过 javaws.exe 启动程序。唯一的选择是 javajavaw

我想要一个能够:

  • 生成不需要 JVM 的独立 .exe 文件预安装
  • 解析 .jnlp 文件并在必要时确定要下载的正确 JVM(我知道 Java Web Start 可以在必要时下载 JVM,但我想避免下载两个,即首先引导 Java Web Start,第二个运行可能需要特定但不同 JVM 的应用程序。)
  • 自动下载并安装 JVM,而不是简单地将用户引导至 Java 下载页面或打开新的安装向导。
  • 如有必要,提示输入管理员密码(用于安装 JVM 的权限。我认为 Sun JVM 安装程序中没有内置此功能。)
  • 仅显示一个安全对话框(我想仅提示用户一次,以确认他们信任生成的 .exe,但我不希望出现第二个提示来确认他们信任 .jar 文件,该文件将来自相同的源并使用相同的证书签名。)我认为这需要自动下载程序在启动 JWS 之前安装证书。)
  • (不是必需的)与 JVM 同时在后台下载应用程序资源(例如 .jar 文件)。这需要在安装 JVM 之前运行缓存,因此缓存必须在本机代码中实现,并且 DownloadService 稍后将使用 JNI 与其连接。

有这样的产品吗?我怀疑它不会,但值得一试。


更新我发现这篇文章 提供了一些相关问题的解决方案,尽管它是为离线安装而设计的,而我最关心的是在线安装。

I have a working JNLP application which I need to distribute to various non-technical end users.

If the user's machine has a recent JVM installed, everything is fine. They just double-click the JNLP file I send them and Java Web Start does the rest.

Now I would like to distribute something that works with or without a JVM, e.g. a .exe file that auto-downloads a compatible JVM if none is present, then invokes javaws.exe to download the .jar files and launch the application.

Launch4J is the closest match I have found, but it cannot launch a program through javaws.exe. The only options are java and javaw

I would like a product that can:

  • Generate a self-contained .exe file that does not require a JVM to be pre-installed
  • Parse the .jnlp file and determine the correct JVM to download if necessary (I know Java Web Start can download a JVM if necessary, but I want to avoid having to download two, the first to bootstrap Java Web Start and the second to run the application which may require a specific but different JVM.)
  • Download and install the JVM automatically, not simply direct the user to a Java download page or open a new installation wizard.
  • Prompt for an admin password if necessary (for permissions to install the JVM. I don't think this is built into the Sun JVM installers.)
  • Show only one security dialog (I would like to prompt the user just once, to confirm they trust the generated .exe, but I do not want a second prompt to confirm they trust the .jar file which will be from the same source and signed with the same certificate.) I assume this will require the auto-downloader to install the certificate before launching JWS.)
  • (not essential) Download application resources (e.g. .jar files) in the background simultaneously with the JVM. This would require the cache to be running before the JVM is installed, so the cache would have to be implemented in native code and the DownloadService would later interface to it using JNI.

Does a product like this exist? I suspect it does not but It's worth a shot.


Update I found this article which has solutions to some related problems, though it is designed for offline installation and I am mostly concerned with online installation.

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

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

发布评论

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

评论(6

单调的奢华 2024-09-19 11:24:04

我已经能够做到这一点&在生产中使用它。

编写一个简单的引导类,将其打包,然后 Launch4j 将其打包。

这是简单引导类的主要内容:

public static void main(String[] args) {
  try {     
    final File jnlp = File.createTempFile("temp", ".jnlp");
    final URL url = new URL("http://yourjnlp-wherever-youre-hostingit.jnlp");
    yourCopyStreamMethodYouWrote(url.openStream(),new FileOutputStream(jnlp));
    Desktop.getDesktop().open(jnlp);
  } catch (final Throwable t) { 
     // do something useful here
  }
}

I have been able to do this & use it in production.

write a simple bootstrap class, jar it, and Launch4j the jar.

here's the main for the simple bootstrap class:

public static void main(String[] args) {
  try {     
    final File jnlp = File.createTempFile("temp", ".jnlp");
    final URL url = new URL("http://yourjnlp-wherever-youre-hostingit.jnlp");
    yourCopyStreamMethodYouWrote(url.openStream(),new FileOutputStream(jnlp));
    Desktop.getDesktop().open(jnlp);
  } catch (final Throwable t) { 
     // do something useful here
  }
}
三生路 2024-09-19 11:24:04

您还可以考虑使用 Excelsior JET 编译您的项目。除此之外,它还创建了一个合理规模的自给自足的分布。

You can also consider compiling your project with Excelsior JET. Apart from everything else it also creates a self-sufficient distribution of reasonable size.

遮云壑 2024-09-19 11:24:04

我遇到了同样的问题。我最终得到了一个 BAT、一个 Shell 以及最终的 Mac 版 DMG。

我发现关于使用 Nullsoft 安装程序为 Windows 自动安装 JRE 的评论:

http://nsis.sourceforge.net/Java_Launcher_with_automatic_JRE_installation< /a>

我认为在 JNLP 之外,您会发现很难实现所有平台的自动化。然而,在我的项目中,两年来,我还没有看到用户必须自己获取 java 的抱怨。我相信大多数机器已经具备了。 Windows 用户抱怨没有快捷方式,但使用 vbs 很容易做到。

同样在 Mac DMG AppBundle 上,它们是指定 JRE 的方法。 Mac 将拥有最新版本,除非是基于 PowerPC 的旧机器。在这种情况下就没有Java6了。

如果您最终拥有多个启动器,我会推荐自动更新策略。

I've run into the same problem. I ended up with a BAT, a Shell and eventual a DMG for Macs.

I found this comment on automaded JRE installation for Windows using Nullsoft installer:

http://nsis.sourceforge.net/Java_Launcher_with_automatic_JRE_installation

I think outside JNLP you will find hard to get automation for all platforms. However on my project, up for two year, I haven't seen complains about users having to get java by themselves. I believe most machines will have it already. Windows user complained about not having a shortcut, but that is easy to do using vbs.

Also on the Mac DMG AppBundle, their is way to specify the JRE. Mac will have the lastest version, unless the are older PowerPC based machines. In that case no Java6.

Of you end up with several launcher, I would recommend an automated update strategy.

時窥 2024-09-19 11:24:04

另一种方法可能还分发带有 .BAT 文件的 Sun JRE,通过 /S 开关调用它,这会导致静默安装。

我还没有看到任何其他允许完全静默的 Java 安装与调用 javaws 相结合的方法。

Another approach might be also distributing a Sun JRE with a .BAT-file invoking it with the /S switch, which cause a silent install.

I have not seen anything else allowing for a completely silent Java install combined with invoking javaws.

你是我的挚爱i 2024-09-19 11:24:04

好吧,我明白你想要做什么,但你为什么不想使用 javaws 呢? Launch4J 看起来是替代安装 java 的一个不错的选择,因为它将允许无缝使用 jar 文件。

javaws 或多或少使用具有安全权限和一些启动选项的 java.exe。但如果您使用用户信任的证书,则可以禁用安全权限。

我也不确定 javaws 何时被引入,但我确信它在 java 1.5 中可用,我已经接近 EOL 了。因此,除非您的用户多年没有安装 java,否则我怀疑让他们启动 jnlp 会是一个问题。即使它们运行的​​是旧版本,您也可以将所需的 java 版本添加到 jnlp,并且只会为该应用程序自动下载该版本。

Ok i get what you are trying to do but why don't you want use javaws? Launch4J looks like a good option as alternate to having java installed, as it will allow seamless usage of the jar file.

javaws is more or less uses java.exe with security permissions and some launch options. But the security permissions can be disabled if you use a certificate that the user trusts.

Also i am unsure when javaws was introduced but i am sure it was available in java 1.5 which i near EOL. So unless your user has not had a java installed for many years i doubt getting them to launch jnlp would be a problem. Even if they are running an older version you can add a required version of java to the jnlp and this will be automatically downloaded for that application only.

烙印 2024-09-19 11:24:04

虽然非商业用途不是免费的,Install4j 提供了一个本机安装程序系统对于 Java 应用程序。支持 JRE 捆绑。我不确定它是否可以自动解析 JNLP,但它可能值得一试。

作为示例用例,基于 Java 的 集成基因组浏览器 与由此生成的安装程序一起分发工具。请参阅其 install4j 配置文件

Though not free for non-commercial use, Install4j offers a native installer system for Java applications. JRE bundling is supported. I am not sure it can parse JNLP automatically, but it may be something worth checking out.

As an sample use case, the Java-based Integrated Genome Browser gets distributed with an installer generated by this tool. See its install4j configuration file.

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