So I am trying to use the library called PreferencesFX, which uses FontAwesomeFX which throws the following error.
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.loadFont(GlyphsFactory.java:64)
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.<init>(GlyphsFactory.java:38)
at de.jensd.fx.fontawesomefx.fontawesome/de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory.<init>(FontAwesomeIconFactory.java:28)
at de.jensd.fx.fontawesomefx.fontawesome/de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory.get(FontAwesomeIconFactory.java:33)
at com.dlsc.preferencesfx@11.7.0/com.dlsc.preferencesfx.view.UndoRedoBox.<init>(UndoRedoBox.java:17)
at com.dlsc.preferencesfx@11.7.0/com.dlsc.preferencesfx.PreferencesFx.init(PreferencesFx.java:71)
at com.dlsc.preferencesfx@11.7.0/com.dlsc.preferencesfx.PreferencesFx.<init>(PreferencesFx.java:64)
at com.dlsc.preferencesfx@11.7.0/com.dlsc.preferencesfx.PreferencesFx.<init>(PreferencesFx.java:55)
at com.dlsc.preferencesfx@11.7.0/com.dlsc.preferencesfx.PreferencesFx.of(PreferencesFx.java:102)
at my.package.tryThis(Clusters.java:38)
at my.package.Main.main(Main.java:17)
... 11 more
Caused by: java.lang.NullPointerException
at de.jensd.fx.fontawesomefx.commons/de.jensd.fx.glyphs.GlyphsFactory.loadFont(GlyphsFactory.java:62)
... 21 more
Exception running application my.package.Main
I found the cause of the problem to sit at line 62 of the Glyphs Factory class but I have no idea how to fix it.
The method GlyphsFactory.class.getResource(pathToIconFont)
returns null
, instead of returning the font file. I can see that the method is loading the font file via path /de/jensd/fx/glyphs/fontawesome/fontawesome-webfont.ttf
(which seem to be correct). I can see that the font is loaded from package de.jensd.fx.glyphs.fontawesome
to package de.jensd.fx.glyphs
but both packages are in different jars.
Any ideas why getResource()
returns null
? I reported it to the developer but it seems the FontAwesomeFX library is abandoned.
I am running this with newest IntelliJ on a Mac OS X Big Sur.