在jpackage之后运行JavaFX应用程序 [英] running JavaFX application after jpackage

查看:286
本文介绍了在jpackage之后运行JavaFX应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实有一些菜鸟问题. 我尝试在OpenJDK 14中使用jpackage为测试应用程序创建安装.这是我所做的:

I have some really noob question. I tried to create installation for my test app with jpackage in OpenJDK 14. Here is what I did:

首先,使用

jlink --module-path "C:\Java\javafx-sdk-14\lib" --add-modules javafx.controls,javafx.fxml --output hello\myjre

那成功了.我从运行配置"中的Eclipse复制了参数.之后,使用jpackage进行安装

and that was successful. I copied arguments from my Eclipse from Run Configurations. After that made installation with jpackage

jpackage --name HelloFX --input hello --main-jar HelloFX.jar --runtime-image hello\myjre

那个创建了.msi文件,我运行它并在Win10应用程序中创建了条目.当然,我不知道如何在Windows菜单中找到它,但是它位于我的C:\ Program Files \ HelloFX中.当我尝试运行应用程序消息无法启动JVM"时,我找到了带有Duke映像的Icon和Application文件.

That created .msi file, I run it and it created entry in my Win10 applications. Of course, I have no idea how to find that in windows menu, but it is placed in my C:\Program Files\HelloFX. I located Icon and Application file with Duke image, when I tried to run application meesage "Failed to launch JVM" pop up.

有人可以帮助我,我做错了什么?我真的很想完成这项工作,并深入研究JavaFX.

Can someone help me, what am I doing wrong? I really want to make this work and dive deeply in JavaFX.

推荐答案

JavaFX SDK附带的JavaFX JAR不包含本机代码.而是,所述代码在bin目录中.这意味着由jlink创建的自定义运行时映像没有运行JavaFX所需的本机代码.您有两种选择:

The JavaFX JARs included with the JavaFX SDK do not include the native code. Instead, said code is in the bin directory. That means your custom runtime image created by jlink does not have the necessary native code to run JavaFX. You have two options:

  1. 从Gluon下载> JMOD文件,并在创建自定义运行时映像时使用这些文件.您可以将JMOD文件放置在--module-path 而不是常规JAR文件中.

  1. Download the JMOD files from Gluon and use those when creating the custom runtime image. You would put the JMOD files on the --module-path instead of the regular JAR files.

使用发布到Maven Central的JavaFX JAR代替SDK. Maven Central JAR嵌入了本机代码.

Use the JavaFX JARs that are published to Maven Central instead of the SDK. The Maven Central JARs embed the native code.

在两种情况下,请确保为您的操作系统使用JMOD/JAR文件-JavaFX是特定于平台的.

In both cases, make sure to use the JMOD/JAR files for your operating system—JavaFX is platform-specific.

我相信第一个选择是最好的.当将JMOD文件与jlink一起使用时,本机代码包含在自定义运行时映像中,其方式与JRE特有的本机代码相同.如果您使用第二种方法,则本机代码仍将包含在自定义运行时映像中,但是必须先将其提取到计算机上的某个位置(例如<user-home>/.openjfx),然后才能使用 1 .换句话说,第一种选择是更清洁.

I believe the first option is the best. When using JMOD files with jlink the native code is included with the custom runtime image in the same way as the native code specific to the JRE. If you use the second approach the native code will still be included with the custom runtime image but it will have to be extracted to some location on your computer (e.g. <user-home>/.openjfx) before it can be used1. In other words, the first option is cleaner.

1.请注意,此提取是由JavaFX自动完成的.

这篇关于在jpackage之后运行JavaFX应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆