Reputation: 1
I'm following the JavaFX Getting Started Guide on https://openjfx.io/openjfx-docs/
I have a basic JavaFX project on Eclipse which run perfectly. Now I would like to generate an executable from this project, on Windows, MacOS and Linux (in order to make my own tutorial).
The code is given by OpenJFX.io : https://github.com/openjfx/samples/tree/master/IDE/Eclipse/Non-Modular/Java
I am at the step where I need to generate a .jar file.
As described in the tutoriel, I am facing this error :
Warning: If you now run the project it will compile but you will get this error:
Error: JavaFX runtime components are missing, and are required to run this application This error is shown since the Java 16 launcher checks if the main class extends javafx.application.Application. If that is the case, it is required to have the javafx.graphics module on the module-path.
JavaFX runtime components are missing error
To get over it, I need to add this argument : --module-path /path/to/javafx-sdk-17/lib --add-modules javafx.controls,javafx.fxml
But when I generate a .jar file with Eclipse (File -> Export -> Runnable JAR file), it tells me that my argument will not be part of the runnable JAR, but it can be passed on the command line when laughing the JAR.
So I have my JAR, I cannot run it with the simple line java -jar MyJar.jar I need to add the --module-path parameter before, like this :
java --module-path /PATH_TO_SDK --add-modules javafx.controls,javafx.fxml -jar MyJar.jar
My question is : I want to create a simple executable, without asking my user any configuration, how can I do it ?
Upvotes: 0
Views: 1021
Reputation: 1
You can't create without arguments, but as the openjfx tutorial also say, you can use jlink and then create a .exe, .deb etc., Use JLink to create binarys and then use jpackage to create the .exe, .deb etc. You can find a tutorial for jlink + jpackage + javafx here: https://dev.to/cherrychain/javafx-jlink-and-jpackage-h9
Upvotes: 0