javaFX program not working after changing the scene builder and jdk

前端 未结 1 1515
暖寄归人
暖寄归人 2020-12-06 19:28

My program worked perfectly before, And I changed my scene builder to gluon scene builder 10 from JavaFx scene builder 2.0 to add some CSS styling. I added the styling and t

相关标签:
1条回答
  • 2020-12-06 20:04

    This error:

    Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/css/parser/CSSParser
    at de.jensd.fx.glyphs.GlyphIcon.<clinit>(GlyphIcon.java:48)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    

    indicates that one of your dependencies (de.jensd.fx.glyphs.GlyphIcon) is trying to access a non existing class (com.sun.javafx.css.parser.CSSParser) in your JDK 9/10.

    With the Java 9 release, many JavaFX classes that were private (com.sun.javafx.*) were moved to public API (in this case, javafx.css.parser.CSSParser).

    If you run on Java 9 or 10, you have to use third party dependencies at least compatible with Java 9.

    From the list of your dependencies:

    • ControlsFX

    8.40.11 is compatible with Java/JavaFX 8. You need to use ControlsFX 9.0.0

    You can download the jar from Maven Central, or add the maven/gradle coordinates:

    <dependency>
        <groupId>org.controlsfx</groupId>
        <artifactId>controlsfx</artifactId>
        <version>9.0.0</version>
    </dependency>
    

    or:

    compile 'org.controlsfx:controlsfx:9.0.0'
    
    • FontAwesomeFX

    FontAwesomeFX 8.15 is also compatible with Java/JavaFX 8, so you need to use the 9 versions:

    Jars: fontawesomefx-commons, fontawesomefx-controls

    or dependencies:

    compile 'de.jensd:fontawesomefx-commons:9.1.2'
    compile 'de.jensd:fontawesomefx-controls:9.1.2'
    

    others:

    compile 'de.jensd:fontawesomefx-emojione:3.1.1-9.1.2'
    compile 'de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2'
    compile 'de.jensd:fontawesomefx-icons525:4.2.0-9.1.2'
    compile 'de.jensd:fontawesomefx-materialdesignfont:2.0.26-9.1.2'
    compile 'de.jensd:fontawesomefx-materialicons:2.2.0-9.1.2'
    compile 'de.jensd:fontawesomefx-octicons:4.3.0-9.1.2'
    compile 'de.jensd:fontawesomefx-weathericons:2.0.10-9.1.2'
    

    Finally, as posted in comments, the warning is just an indication that your FXML was created with a newer version that the JDK running it. It can be ignored.

    0 讨论(0)
提交回复
热议问题