简体   繁体   English

Jpackage 不能与 JDBC 依赖项完美配合

[英]Jpackage doesn't work perfectly with JDBC dependency

I've made a simple program that uses JavaFX and JDBC as dependencies, I packaged it to an installable file using jpackage, with no difficulties, but when I try to launch my program it gives me the following error:我制作了一个使用 JavaFX 和 JDBC 作为依赖项的简单程序,我使用 jpackage 将它打包到一个可安装的文件中,没有任何困难,但是当我尝试启动我的程序时,它给了我以下错误:

"Missing JavaFX application class com.example.mvnwithjdbcnotused.HelloApplication"

PS: the program is runing fine in the IDE, also with CMD (runing the ".jar" file not the installed file), it's just the resulted.exe file that gives that error. PS:该程序在 IDE 和 CMD 中运行良好(运行“.jar”文件而不是安装的文件),只是产生该错误的 resulted.exe 文件。 i tried to make the same program but without calling or using mysql database, and it worked fine, so i assumed the problem is related to the dependency (which is MySQL JDBC) or the way i used the Jpackage tool我尝试制作相同的程序,但没有调用或使用 mysql 数据库,它工作正常,所以我认为问题与依赖项(即 MySQL JDBC)或我使用 Jpackage 工具的方式有关

Steps i followed to create the installable.exe我遵循的步骤来创建 installable.exe

1-i packaged my files using Intellij's artifact (including all the dependencies used) 1-i 使用 Intellij 的工件打包我的文件(包括所有使用的依赖项)

2-i used jpackage tool as follow: 2-我使用 jpackage 工具如下:

jpackage --name "name of the file" --description "description" --vendor "vendor" --app-version 1.0 --input "the file that has the .jar created by the first step" --main-jar "name of the jar"--dest "destination file " --module-path "path to javafx jmods files " --add-modules javafx.controls,javafx.fxml --win-console

3-install the file 3-安装文件

4-run the program 4-运行程序

I'm really confused if the issue is from the steps i followed or from the dependency or the tool如果问题是来自我遵循的步骤或来自依赖项或工具,我真的很困惑

the last think i want to mention is my project is modular, but MySQL JDBC is not.我最后想提的是我的项目是模块化的,但 MySQL JDBC 不是。

You should edit your question with more details, and when I am near my PC will update this answer.你应该用更多的细节来编辑你的问题,当我靠近我的电脑时会更新这个答案。

In order for jpackaged exe to run JavaFX with JDBC your jpackage app must contain the all the dependent jar or modules.为了使 jpackaged exe 运行 JavaFX 和 JDBC,您的 jpackage 应用程序必须包含所有相关的 jar 或模块。 One way is to use jlink to collect your dependent modules as one image.一种方法是使用 jlink 将依赖模块收集为一个图像。 Jpackage does this implicitly or you can see this answer. Jpackage 隐式执行此操作,或者您可以看到此答案。 Include jdbc drivers in jlink command if they are modular.如果它们是模块化的,请在 jlink 命令中包含 jdbc 驱动程序。 Test your own application works with the JRE created by jlink.测试您自己的应用程序是否与 jlink 创建的 JRE 兼容。

how can I get javafx 14 to compile and run? 我怎样才能让 javafx 14 编译运行?

Then use this jlink image in jpackage.然后在 jpackage 中使用这个 jlink 图像。

How can I convert my Java program to an.exe file? 如何将我的 Java 程序转换为 .exe 文件?

Additional jar dependencies must also be copied into the image using --input .还必须使用--input将其他 jar 依赖项复制到映像中。 Setup a jpackage.image folder with additional classpath jars, property files etc which can be used within cfg files as $APPDIR使用附加类路径 jars、属性文件等设置jpackage.image文件夹,这些文件可以在cfg文件中用作$APPDIR

https://stackoverflow.com/questions/63551326/jpackage-incubator-and-sqlite-database-problem/63558363?r=SearchResults&s=5|19.2953#63558363 https://stackoverflow.com/questions/63551326/jpackage-incubator-and-sqlite-database-problem/63558363?r=SearchResults&s=5|19.2953#63558363

This will not work the way you are trying to do this because this way jpackage cannot handle non-modular dependencies.这不会像您尝试这样做的方式那样工作,因为这样 jpackage 无法处理非模块化依赖项。 You have to use jlink and jpackage separately.您必须分别使用 jlink 和 jpackage。 The details are described here: https://github.com/dlemmermann/JPackageScriptFX详情在这里描述: https://github.com/dlemmermann/JPackageScriptFX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM