1

I had to switch from Linux back to Windows 10 for battery-life issues, and I cannot add JavaFX to Netbeans. Using JDK 16, latest version of JavaFX. I've created a JavaFX library and added the .jars but, Unlike in my linux version of Netbeans, in windows there is no option to add libraries to the project from the project > properties menu. How can I get my projects to find my JavaFX library?

I've been looking through similar questions here, but I couldn't find one that solved this specific problem.

  • You need to downgrade to JDK 8 in windows as JavaFX has been removed after JDK 8 in oracle-JDK. In Linux, you must be using open-JDK which still supports JavaFX in later versions. – Shekhar Rai May 25 '21 at 05:15
  • Start [here](https://openjfx.io/openjfx-docs/). – SedJ601 May 25 '21 at 05:41
  • @Shekhar I was finally able to get it to work in Eclipse with JDK 16. I had to add all the javaFX .jars to a user library and add it to the projects module path, then add a VM argument adding all the jars. `--module-path="C:\Program Files\OpenJFX\javafx-sdk-11\lib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.graphics,javafx.media,javafx.swing,javafx.web,javafx.swt` Thanks for the help! – irl_notsure May 26 '21 at 18:07

1 Answers1

0

You can right-click on the Libraries folder in the project explorer and choose "Add Project" or "Add library" then select your JavaFX project/library accordingly:

enter image description here

sorifiend
  • 5,927
  • 1
  • 28
  • 45
  • There is no Libraries folder... just Source, Test, Dependencies, and Project files – irl_notsure May 24 '21 at 22:59
  • It sounds like you have used a different project template than what you need. Start a new project and choose a different template/type that allows you to use libraries? – sorifiend May 24 '21 at 23:05
  • Ok so on Linux I simply created Java with Maven > java application projects and they included the libraries folder. Now on Windows, I can't get a libraries folder unless I create a Java with ANT > Java application. I was using the same version of Netbeans on both, any Idea what is going on here? – irl_notsure May 24 '21 at 23:14
  • Ahh right, you'll need to add it manually for Maven projects, this answer does a great job explaining the steps: https://stackoverflow.com/a/21340440 – sorifiend May 24 '21 at 23:22
  • Thanks, that did get rid of the complaints about the imports, and it built successfully. However, now I am getting "Error: JavaFX runtime components are missing, and are required to run this application " when I try to run the program. – irl_notsure May 25 '21 at 00:05
  • Excellent to hear. From memory the JavaFX error is caused by missing JavaFX components, you need to make sure you have all the supporting JavaFX libs/jars included, and that they are present in the local/manual directory. – sorifiend May 25 '21 at 00:08
  • OK, so not sure what is going on now. I have all the .jars from openjfx SDK in the dependencies. There was nothing else included in the jfx download that I missed. Here is the full error: `Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.base not found C:\Users\irl\Documents\NetBeansProjects\javaFXIntro\nbproject\build-impl.xml:1366: The following error occurred while executing this line: C:\Users\irl\Documents\NetBeansProjects\javaFXIntro\nbproject\build-impl.xml:993: Java returned: 1 BUILD FAILED (total time: 1 second)` – irl_notsure May 25 '21 at 00:18
  • This may be helpful: https://stackoverflow.com/questions/49520858/error-occurred-during-initialization-of-boot-layer-findexception-module-not-fou – sorifiend May 25 '21 at 00:19
  • ...Still wont budge. Thanks for all your help. I was trying to get it to work with eclipse too at the same time and neither one wants to play nice with javaFX. I just switched to BlueJ and it's working fine so looks like I found a solution! – irl_notsure May 25 '21 at 01:39