Reputation: 195
I created a '.exe' file for a JavaFX application on Windows 10 using jpackage. Afterward, by double-clicking on the application's icon, the app did not start. I realized that I mistakenly used this command, which is tailored for none modular application:
jpackage --input app-directory --main-jar jar-file [--main-class main-class]
Now I am trying to use the proper command syntax from Oracle doc for Modular application:
jpackage --module-path module-path --module main-module[/class]
Here is my command based on the syntax given by Oracle:
jpackage -p "%JAVAFX_HOME%\lib;%M2_REPO%;org\openjfx\mavenfxedittableview\mavenfxedittableview.jar" --module "org.openjfx.mavenfxedittableview/org.openjfx.mavenfxedittableview.TableEditApp"
However, I am getting an error regarding jlink not using automatic modules: The error message:
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
My application module name in the module-info.class is
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;
}
The application main is org.openjfx.mavenfxedittableview.TableEditApp and the org\openjfx\mavenfxedittableview directory structure is a relative path within the "c:\sample" directory.
The build classes are:
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
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
This is the jar manifest file:
Manifest-Version: 1.0
Main-Class: org.openjfx.mavenfxedittableview.TableEditApp
Created-By: 14.0.2 (Oracle Corporation)
Finally, I found out about this Maven plugin ModiTect:
https://www.youtube.com/watch?v=BhuOSGrNBek
, which embeds a descriptor into the jar file of an automatic module, however that would be extremely tedious and time-consuming since the culprit automatic module is not even in my module descriptor. This implies that I might have to go through the .m2 repository and convert them one by one. Are there better work arounds?
Thanks
Upvotes: 2
Views: 2034
Reputation: 10650
You might want to follow this tutorial: https://github.com/dlemmermann/JPackageScriptFX It also uses jpackage and jlink but in a way that makes it usable for non-modular projects. You can't use jlink directly because it does not support automatic modules but this problem can be avoided by just not using the module system at all.
Upvotes: 2