3

I am creating javafx projects in STS(4.6.1) with e(fx)clipse plugin and scenebuilder.

Everytime I create a new project, I have to add the VM arguments in run configurations:

--module-path "/home/path/to/javafx sdk/lib" --add-modules javafx.controls,javafx.fxml

otherwise the program ends with the error message which says

Error: Could not find or load main class application.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

I have to do this for every javafx project which is irritating.

Is there a way to add this once and for all?

Thanks

dhakalkumar
  • 161
  • 1
  • 3
  • 14
  • 2
    When your own program depends on the modules `javafx.controls` and `javafx.fxml`, you should declare the dependency in a `requires` directive in the module declaration. There is no way around configuring a module path, until you package your final product to something containing all required modules, but does your IDE not have project templates? Just create a “JaxaFX Project” template with the module path. – Holger Jul 02 '20 at 08:11
  • Explored the modules in the project creation dialog. But I cannot find any modules related to javafx [https://i.postimg.cc/FKh7Xgsf/Screenshot-from-2020-07-03-07-55-51.png] [https://i.postimg.cc/d0nDskL5/Screenshot-from-2020-07-03-07-56-03.png] Do I have to add them manually? – dhakalkumar Jul 03 '20 at 02:20
  • 1
    Did you set up the module path first? – Holger Jul 03 '20 at 08:07
  • No! How do I set it up? – dhakalkumar Jul 03 '20 at 08:35
  • 1
    Check the “Libraries” tab – Holger Jul 03 '20 at 08:39
  • Added javafx jars in the Libraries tab, but that did not change anything. Now I'm using maven to create the javafx projects and that's working fine! – dhakalkumar Jul 06 '20 at 05:36

1 Answers1

2

You can create your own variable in Eclipse with the specific value. When you need this value you can then choose from the variables list and add it to VM arguments by creating a variable in Eclipse to store the VM arguments.

rfreytag
  • 955
  • 1
  • 8
  • 24
kmagdi
  • 36
  • 2