install4j 安装完成后启动 Java Web Start 应用程序
我试图在安装完成后启动 install4j 启动器,但它不起作用。不过,启动器作为开始菜单项工作得很好。我有理由相信这是因为我的应用程序是通过 Java Web Start 启动的(必须是出于法律原因)。
单击 install4j 安装程序中的完成按钮时会发生什么:
- 安装程序窗口消失,Java WebStart 启动(显示启动画面)。
- 没有再发生任何事情(通常我的 Java 应用程序会从这里启动)。
通过查看 Java 日志,我可以看到 WebStart 实际上执行了我的 Java 应用程序,但它无法完全启动,因为文件 C:\Users\UserName\AppData\Local\Temp\e4j2E4E.tmp_dir\jre\lib\ext \dnsns.jar 不再存在。这个目录似乎是install4j临时放置它需要运行的JRE的地方。
通过在文件管理器中按 F5,我可以看到 JRE 在执行 WebStart 后被删除(我猜是通过 install4j)。这可以解释为什么我的 Java 应用程序会失败。
当运行开始菜单启动器(安装后手动)时,一切正常,因为我的 Java 应用程序随后使用与其捆绑在一起的 JRE(在其自己的子文件夹中)。
如何防止 install4j 删除临时 JRE,或强制 WebStart 使用另一个(捆绑的)JRE 执行我的 Java 应用程序?
预先感谢您的任何建议!
==编辑== 这就是我的应用程序的启动方式:install4j Launcher 启动我的一个 Java 类,该类启动 javaws 二进制文件,从而启动我的主 Java 应用程序。
I'm trying to start an install4j Launcher upon installation finish, but it doesn't work. The Launcher works fine as a start menu item though. I have reasons to believe that this is because my application is started through Java Web Start (it has to be for legal reasons).
What happens when clicking the finish button in my install4j installer is:
- The installer window disappears and Java WebStart starts (showing its splash).
- Nothing more happens (normally my Java application would start here).
By looking in the Java log, I can see that WebStart actually executes my Java app, but that it fails to fully start because the file C:\Users\UserName\AppData\Local\Temp\e4j2E4E.tmp_dir\jre\lib\ext\dnsns.jar doesn't exist anymore. This directory seem to be the place where install4j temporary places the JRE that it needs to run.
By hitting F5 in a file manager, I can see that the JRE is removed (I guess by install4j) after WebStart has been executed. This would explain why my Java app then fails.
When running the start menu launcher (manually after installation), everything works fine because my Java app is then using the JRE that is bundled with it (in a subfolder of its own).
How can I prevent install4j to remove the temporary JRE, or force WebStart execute my Java app with another (the bundled) JRE?
Thanks in advance for any suggestions!
==EDIT==
This is how my application is started: An install4j Launcher starts a Java class of mine, that starts a the javaws binary, which starts my main Java application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您通过“运行可执行文件”操作启动网络启动。您是否使用 System.getProperty("java.home") 来获取当前 JRE 的位置?这将产生临时提取的 JRE,该 JRE 将在安装程序退出后删除。
您应该使用 sys.preferredJre 安装程序变量。在文本字段中输入
${installer:sys.preferredJre}
,在脚本中使用context.getVariable("sys.preferredJre")
。运行“安装文件”操作后,该变量将包含已安装 JRE 包的位置。I assume that you start web start with a "Run executable" action. Do you use
System.getProperty("java.home")
to get the location of the current JRE? That would yield the temporarily extracted JRE that is deleted after the installer exits.You should use the
sys.preferredJre
installer variable instead. In text fields, enter${installer:sys.preferredJre}
, in scripts usecontext.getVariable("sys.preferredJre")
. After the "Install files" action has run, the variable will contain the location of the installed JRE bundle.