I tried installing javaFX on my eclipse and it worked fine at first. Then I decided I want to make a specific JRE to save me from doing all the extra steps (adding user library each time, etc..) and I think I followed the tutorial well but now the programs won't run and I get this message from the JVM launcher: (Error:--add-- modules requires modules to be specified) note: the compilation works fine but after running it that happens
I'm not very experienced with these types of things and I have no idea what I did wrong so please ask me for any necessary details any suggestions?
CodePudding user response:
Information on VM arguments for adding modules is in the documentation:
Add VM arguments To solve the issue, click on
Run -> Run Configurations... -> Java Application
create a new launch configuration for your project named
hellofx
and add these VM arguments:--module-path "\path\to\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml
This should be done if the JDK or JRE you are using does not include the JavaFX modules in its base module layer (which applies to most common JDK or JRE distributions) and you are executing your application via the IDE (e.g. not via maven with the javafx-maven-plugin).
FAQ
Then I decided I want to make a specific JRE to save me from doing all the extra steps
You don't need to build your own JRE with JavaFX modules.
You can use a pre-built JRE (or JDK) that includes JavaFX:
With either of those, the JavaFX modules are included in the base JDK. That means you don't specify JavaFX libraries in build tool dependencies, or manually in the IDE, and you don't need compile or VM arguments for JavaFX modules.