Issue
We are working on Javafx project which was working fine on Java8. Recently, We have updated the project with Java17. We are able to resolve the issues for the IDEA.
Seems like after Java 9+ they have strictly encapsulated all classes. To use this we have to use "export" "open" keywords in vm options or define "ALL-UNNAMED" in the compile runtime.
This is running perfectly on IDEA. Now, We are trying to load fxml files in scene builder but scenebuilder unable to find out these classes. We have added all required jar files to scenebuilder but still unable to load the FXML files.
Following errors scenebuilder showing:
java.lang.ClassNotFoundException: com.sun.javafx.scene.TreeShowingExpression
Libraries we are using:
jfoenix.jar. fx_progress_circle.jar. fontawesomefx.jar
We are getting issues on the JFX views on JFXCheckbox, JFXRadioButton, JFXSpinner etc.
We have tried every possible solution, but couldn't solve it.
Any help would be appreciated. thanks.
Solution
Importing jfoenix and fontawesomefx libraries:
- Click the Settings Icon in the Scene Builder Library Panel
- Choose JAR/FXML Manager
- Choose Search Repositories
- Search for jfoenix, and fontawesomefx
- Choose the following libraries:
- com.jfoenix:jfoenix
- de.jensd:fontawesomefx-fontawesome
- Scene Builder will import the latest lib version of each:
- com.jfoenix:jfoenix:9.0.10
- de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2.
- All of the imported new components are now selectable in the Custom section of the library manager.
The progress circle thing isn't in Maven central, you will need to import it via the "Add Library/FXML from File System" option of the "JAR/FXML Manager" dialog (I didn't try that).
jfoenix github page says it needs to be 9+ to work with Java 9+. I don't think jfoenix is all that well maintained and (from some other questions about the library on StackOverflow), it mostly works in recent SceneBuilder builds, but not well and some of its components don't behave well in SceneBuilder.
Related:
- Importing JFoenix library to SceneBuilder - javaFX
- JFoenix library does not have JFXTabPane support in scenebuilder?
Similarly, fontawesomefx has version 9.1.2 which has a manifest with an automatic module in it maven repo entry, which allows it to work. I don't know where up-to-date documentation on that project is, but it appears that there are multiple packages that you can use depending on the font library you want to access, I just picked the one which uses the fontawesome icon library.
Related:
- FontAwesomeIconView not found in Scene Builder 16.0.0 with openjdk 11.0.10
- Unable to import certain classes in fontawesomefx after updating for Java 9 / Java 11
JavaFX 8 to JavaFX 17 conversion approach advice
I suggest:
- Changing your project to a modular project by defining a module-info.java.
- Using the most recent stable version of Java and JavaFX (17.0.2)
- Using the most recent stable versions of the dependent libraries.
- Importing libraries via a build tool:
- I'd recommend Maven unless you really know Gradle.
- Run the app without any VM options for exports and opens etc.
- Define the module use information in your module-info.
- Ensure that your app works fine in those conditions (fixing any issues that arise).
- Then try to import the same library versions and your fxml into scene builder.
Answered By - jewelsea
Answer Checked By - Senaida (JavaFixing Volunteer)