Jpackage与ControlsFX。

huangapple go评论81阅读模式
英文:

Jpackage with ControlsFX

问题

I’m having some issues including Controlsfx when using Jpackage.

我在使用Jpackage时遇到了一些包含Controlsfx的问题。

I have set up a project in IntelliJ with JavaFX using an Archetype from Maven Central. Works fine with JavaFX in IntelliJ. I can package it with Maven (from IntelliJ) and use JPackage for making an exe-installer, that also works fine. I’m using this command with JPackage:

我在IntelliJ中使用Maven Central的Archetype设置了一个带有JavaFX的项目。在IntelliJ中使用JavaFX没有问题。我可以使用Maven(从IntelliJ中)打包它,并使用JPackage制作一个exe安装程序,也可以正常工作。我在JPackage中使用以下命令:

jpackage --input C:...\target --add-modules javafx.controls --module-path C:...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path --win-console --dest c:\outputs --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

Now I want to incorporate ControlsFX so I download the ControlsFX .JAR from Maven: https://mvnrepository.com/artifact/org.controlsfx/controlsfx/11.1.2IntelliJ
In IntelliJ I add it as a Module. All fine, I wan use ControlsFX in my project.

现在我想要加入ControlsFX,所以我从Maven下载了ControlsFX的.JAR文件:https://mvnrepository.com/artifact/org.controlsfx/controlsfx/11.1.2IntelliJ
在IntelliJ中,我将它添加为一个模块。一切都很好,我想在我的项目中使用ControlsFX。

Now I want to make an exe-installer (like above without ControlsFX) so I add ControlsFX to my JPackage command:

现在我想制作一个exe安装程序(就像没有ControlsFX的情况下那样),所以我将ControlsFX添加到我的JPackage命令中:

jpackage --input C:...\target --add-modules javafx.controls,controlsfx --module-path C:...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path C:..\controlsfx --win-console --dest c:\test --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

When running the command I get this:

运行命令时,我收到以下错误:

java.lang.module.FindException: Module controlsfx not found

I know my issue is related to the command I pass to JPackage but can't figure out what is.

我知道我的问题与我传递给JPackage的命令有关,但无法找出问题出在哪里。

英文:

I’m having some issues including Controlsfx when using Jpackage.

I have set up a project in IntelliJ with JavaFX using a Archetype from Maven Central. Works fine with JavaFX in IntelliJ. I can package it with Maven (from IntelliJ) and use JPackage for making an exe-installer, that also works fine. I’m using this command with JPackage:

jpackage --input C:\...\target --add-modules javafx.controls --module-path C:\...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path --win-console --dest c:\outputs --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

Now I want to incorporate ControlsFX so I download the ControlsFX .JAR from Maven: https://mvnrepository.com/artifact/org.controlsfx/controlsfx/11.1.2IntelliJ
In IntelliJ I add it as a Module. All fine, I wan use ControlsFX in my project.

Now I want to make an exe-installer (like above without ControlsFX) so I add ControlsFX to my JPackage command:

jpackage --input C:\...\target --add-modules javafx.controls,controlsfx --module-path C:\...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path C:\..\controlsfx --win-console --dest c:\test --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

When running the command I get this:

java.lang.module.FindException: Module controlsfx not found

I know my issue is related to the command I pass to JPackage but cant figure out what is.

答案1

得分: 5

如下所述,@Slaw在下面的评论中提到,您使用了错误的模块名称。您可以通过查看模块定义来确认jar包的模块名称。这将告诉您在jpackage中使用的模块的名称,例如org.controlsfx.controls,或者如果是非模块jar包,则会打印未找到模块描述符。派生的自动模块。

jar --file=controlsfx.jar --describe-module
org.controlsfx.controls@11.1.2 jar:file:///c:/dev/mods/controlsfx.jar!/module-info.class
...以及出口的详细信息

jpackage命令将在内部使用jlink来构建包含所有列出的模块的运行时映像:

jpackage --input myinput --add-modules javafx.controls,org.controlsfx.controls --module-path c:\xyz...\javafx-jmods-NN --module-path c:\abc...\controlsfx.jar  --dest myoutput {otherargs}

安装后,您可以通过以下方式检查已安装运行时中包含哪些模块:

C:\Program Files\XYZ\runtime\bin\java --list-modules
...
javafx.controls@somever
...
org.controlsfx.controls@somever

或者,您可以将jar包(模块或非模块)复制到目标发布结构的--input目录下的某个位置,然后它将被视为类路径jar依赖项(在发布目录内),而不是模块依赖项(与上述运行时映像内)。您可以通过查看生成的{launcher}.cfg文件来检查是否将jar包添加为类路径依赖项,它应该包含以下一行:

app.classpath=$APPDIR\whateverplaceunder--input.dir\controlsfx.jar
英文:

As mentioned by @Slaw in comments below, you have used the wrong module name. You can confirm the module name of a jar by viewing the module definition. This tells you the name of the module to use with jpackage eg org.controlsfx.controls or will print No module descriptor found. Derived automatic module. if a non module jar:

jar --file=controlsfx.jar --describe-module
org.controlsfx.controls@11.1.2 jar:file:///c:/dev/mods/controlsfx.jar!/module-info.class
... plus details of exports

The jpackage command will use jlink internally to build a runtime image that contains all the modules listed:

jpackage --input myinput --add-modules javafx.controls,org.controlsfx.controls --module-path c:\xyz...\javafx-jmods-NN --module-path c:\abc...\controlsfx.jar  --dest myoutput {otherargs}

After installation you can check which modules are in the installed runtime with:

 C:\Program Files\XYZ\runtime\bin\java --list-modules
 ...
 javafx.controls@somever
 ...
 org.controlsfx.controls@somever

Alternatively you can use a jar (module or non module) with jpackage by copying the jar into your target release structure somewhere under the --input directory. Then it will be picked up as a classpath jar dependency (inside the release directories) rather than as a module dependency (inside the runtime image as above).

You can check if a jar was added as as classpath dependency by looking at the generated {launcher}.cfg, it should contain a line:

 app.classpath=$APPDIR\whateverplaceunder--input.dir\controlsfx.jar

huangapple
  • 本文由 发表于 2023年5月20日 21:39:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76295523.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定