我使用jpackage为Windows 10上的JavaFX应用程序创建了一个“JavaFX”文件。之后,通过双击应用程序的图标,应用程序没有启动。我意识到我错误地使用了这个命令,它是为非模块化应用程序量身定做的:
jpackage --input app-directory --main-jar jar-file [--main-class main-class]现在,我正在尝试使用Oracle文档为模块化应用程序提供的正确的命令语法:
jpackage --module-path module-path --module main-module[/class]下面是基于Oracle提供的语法的命令:
jpackage -p "%JAVAFX_HOME%\lib;%M2_REPO%;org\openjfx\mavenfxedittableview\mavenfxedittableview.jar" --module "org.openjfx.mavenfxedittableview/org.openjfx.mavenfxedittableview.TableEditApp"但是,我收到了一个关于jlink不使用自动模块的错误:错误消息:
WARNING: Using incubator modules: jdk.incubator.jpackage
jlink failed with: Error: automatic module cannot be used with jlink: javafx.swt from file:///C:/Program%20Files/java/jFX/javafx-sdk-14.0.2.1/lib/javafx-swt.jar我在模块-info.class中的应用程序模块名是
module org.openjfx.mavenfxedittableview {
requires javafx.controls;
requires javafx.fxml;
requires java.base;
requires java.prefs;
requires transitive java.xml.bind;
opens org.openjfx.mavenfxedittableview to java.xml.bind, javafx.fxml;
exports org.openjfx.mavenfxedittableview;
}应用程序的主目录是org.openjfx.mavenfxedittableview.TableEditApp,org\openjfx\mavenfxedittableview目录结构是"c:\sample“目录中的一个相对路径。
构建类是:
Directory of C:\Sample\org\openjfx\mavenfxedittableview
09/09/2020 10:32 PM <DIR> .
09/09/2020 10:32 PM <DIR> ..
09/09/2020 08:36 PM 2,502 addressBookData.xml
09/09/2020 08:36 PM 9,562 Address_Book.png
09/09/2020 08:36 PM 859 birthdaystatistic.fxml
09/09/2020 08:36 PM 3,274 BirthdaystatisticController.class
09/09/2020 08:36 PM 3,224 DarkTheme.css
09/09/2020 08:36 PM 2,072 DateUtil.class
09/09/2020 08:36 PM 1,214 LocalDateAdapter.class
09/09/2020 10:32 PM 34,004 mavenfxedittableview.jar
09/09/2020 08:36 PM 3,523 Person.class
09/09/2020 08:36 PM 4,535 personeditdialog.fxml
09/09/2020 08:36 PM 5,128 PersoneditdialogController.class
09/09/2020 08:36 PM 1,029 PersonListWrapper.class
09/09/2020 08:36 PM 6,412 personoverview.fxml
09/09/2020 08:36 PM 1,904 rootlayout.fxml
09/09/2020 08:36 PM 4,490 RootlayoutController.class
09/09/2020 08:36 PM 9,060 TableEditApp.class
09/09/2020 08:36 PM 6,812 TableVieweditController.class
17 File(s) 99,604 bytes
2 Dir(s) 56,574,193,664 bytes free
下面是应用程序jar文件的内容:
0 Wed Sep 09 22:32:14 IRDT 2020 META-INF/
125 Wed Sep 09 22:32:14 IRDT 2020 META-INF/MANIFEST.MF
2502 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/addressBookData.xml
9562 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/Address_Book.png
859 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/birthdaystatistic.fxml
3274 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/BirthdaystatisticController.class
3224 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/DarkTheme.css
2072 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/DateUtil.class
1214 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/LocalDateAdapter.class
3523 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/Person.class
4535 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/personeditdialog.fxml
5128 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/PersoneditdialogController.class
1029 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/PersonListWrapper.class
6412 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/personoverview.fxml
1904 Wed Sep 09 20:36:28 IRDT 2020 org/openjfx/mavenfxedittableview/rootlayout.fxml
4490 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/RootlayoutController.class
9060 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/TableEditApp.class
6812 Wed Sep 09 20:36:30 IRDT 2020 org/openjfx/mavenfxedittableview/TableVieweditController.class
349 Wed Sep 09 22:32:14 IRDT 2020 module-info.class这是jar清单文件:
Manifest-Version: 1.0
Main-Class: org.openjfx.mavenfxedittableview.TableEditApp
Created-By: 14.0.2 (Oracle Corporation)最后,我发现了这个Maven插件ModiTect:
https://www.youtube.com/watch?v=BhuOSGrNBek,它将描述符嵌入到自动模块的jar文件中,但是,这将是非常繁琐和耗时的,因为罪魁祸首自动模块甚至不在我的模块描述符中。这意味着我可能必须遍历.m2存储库并逐个转换它们。周围有更好的工作吗?
谢谢
发布于 2020-09-11 08:21:32
您可能希望遵循本教程:https://github.com/dlemmermann/JPackageScriptFX,它也使用jpackage和jlink,但在某种程度上使其可用于非模块化项目。您不能直接使用jlink,因为它不支持自动模块,但是只要完全不使用模块系统就可以避免这个问题。
https://stackoverflow.com/questions/63836130
复制相似问题