5

I am trying to build the sample javaFX application in the Intellij 2018.3 IDE. I have installed the oracle JDK11, and downloaded openjfk11. I created a library linked to the javafx sdk and added the line --module-path=${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml to the VM options line. PATH_TO_FX is defined as an environment variable pointing to my javaFX folder.

I have searched through a number of postings on this site, including This solution to my exact error message. The odd thing I cannot figure out is, This solution works for me if there is no build directory. But if I have already built the project once, it then refuses to run and gives me the stated error. If I delete the build directory and try again, then the program runs correctly again.

SassyViking
  • 109
  • 1
  • 2
  • 6
  • Sounds like you need to do a clean on the build directory when running your application. – Hypnic Jerk Dec 05 '18 at 20:59
  • 1
    Shouldn't the IDE take care of that for me? I have manually cleaned build directories when I build on the command line, but When using intellij in the past I never had to do anything more than hit the run button to rerun my programs. – SassyViking Dec 06 '18 at 23:30
  • In my case, Intellij was storing the wrong `PATH_TO_FX` in `IntelliJ->File->Settings->Appearance & Behavior->Path Variables`. Changing / removing this path fixed my problem. – Guillaume F. May 25 '20 at 15:25

5 Answers5

2

if you use IntelliJ , you must delete module-info.java in src/main/java, i did and it works, this file is automatically generated when you create javafx project

Sea Pea
  • 21
  • 2
1

Try adding path to JavaFX SDK lib folder instead of just the JavaFX SDK. It worked for me.

ex:

--module-path C:\javaFX\javafx-sdk-11.0.2\lib --add-modules javafx.controls,javafx.fxml

*Replace the "C:\javaFX\javafx-sdk-11.0.2\lib" part with the path to your javaFX SDK "lib" folder.

dovh.me
  • 11
  • 1
1

You should not use VM Path if you define exports and opens in module-info.java. Because VM Path is essential if do not explicitly define module. Then IntelliJ internally creates a module for us.

0

Well It looks like I just goofed up something with the output directory because this morning I tried resetting the build path to the default and it just started working.

SassyViking
  • 109
  • 1
  • 2
  • 6
0

Confirm if you didnt add the javafx sdk to the class path instead of the modulepath

Tony-17
  • 1
  • 1
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 26 '22 at 02:11