0

I am new to JavaFX but I have already watched so much tutorials on YT how to do stuff and such, including connecting fontawesome to JavaFX project. My icons appear properly in the scene builder, but when I launch the app - there are a lot of errors telling that probably library was not found(?).

SCENE BUILDER VERSION: 8.5 (because fontawesome icons dont work with higher versions)

Java SDK: 11

Fontawesome version: 8.9

I tried to connect jar file as a global library in the project's structure - is this a correct way to do that?

This is the error (actually the most valuable part of it)

"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\lib\idea_rt.jar=63160:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\bin" -Dfile.encoding=UTF-8 -p "C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.graphics.jar;C:\Users\ekoal\Documents\Aplikacja\DigitalSchoolDiary\out\production\DigitalSchoolDiary;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11.0.2\lib\javafx.web.jar;C:\Users\ekoal\Downloads\fontawesomefx-8.9.jar;C:\Users\ekoal\Documents\Aplikacja\DigitalSchoolDiary\lib\jfoenix-9.0.8.jar" -m DigitalSchoolDiary/main.Launch
Exception in Application start method
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:566)
    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:566)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javafx.fxml.LoadException: 
/C:/Users/ekoal/Documents/Aplikacja/DigitalSchoolDiary/out/production/DigitalSchoolDiary/views/LoginUI.fxml

    at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
    at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2863)
    at javafx.fxml/javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2707)
    at javafx.fxml/javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2676)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2542)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
    at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
    at DigitalSchoolDiary/main.Launch.start(Launch.java:22)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2931)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2920)
    at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2861)
    ... 20 more
Exception running application main.Launch

Process finished with exit code 1


And this is my fxml import part of the font awesome:

<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>

EDIT:

IML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="JavaFX11" level="application" />
    <orderEntry type="library" name="javaFX11" level="application" />
    <orderEntry type="library" name="fontawesomefx-8.9" level="project" />
    <orderEntry type="library" name="JFoenix-9.0.8" level="project" />
  </component>
</module>

I am not sure if this is what you were asking about - because I have read a lot about dependencies right now and it seems like the more I read about it, the more confused I am. I have added JAR file to the project's libraries folder in the modules section. Also I found post on other site where guy had a similar problem and at the end he said: "I fixed the issue by just updating my jfoenix to version 9.0.6 from 8.0.7"

Unfortunately it didn't worked for me. Could you tell me please - am I connecting this library in a right way?

Alraku
  • 45
  • 1
  • 10
  • Do you have the library or the jar added to the module dependencies? https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#working-with-module-dependencies. – CrazyCoder Apr 18 '19 at 05:01
  • @CrazyCoder I have just checked your advise: 1. went to the modules in the project structure 2. i saw that modules are there but they are not "checked" 3. i checked them and clicked "apply" but still doesn't work - same output. – Alraku Apr 18 '19 at 09:41
  • Checked is for export and is not relevant in this case. Please share the [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – CrazyCoder Apr 18 '19 at 09:42
  • I have reedited my post because giving a part of module-info code was unnecesary as well. Instead of it I posted code of IML file which is for dependencies - am I right? Also I updated a describtion of my problem. It seems like you are the one who understands my problem. – Alraku Apr 18 '19 at 16:01
  • See https://stackoverflow.com/a/51670666/104891. It looks like you need Java 9+ compatible library instead of Java 8. – CrazyCoder Apr 18 '19 at 18:07
  • Sadly it still didn't work for me - I am in a really bad mood because I have just lost almost 10 hours on solving that thing... I tried to download the most fresh versions from repositories in scene builder but after adding jar - no components are visible in Scene builder. Even after downloading manually jar files and adding them into the SB and Intellij idea - still the same problem. What is worse - no matter if it is FontAwesome or JFoenix - same errors so maybe I am wrongly adding them? I tried using maven project but it completly broke my application now. – Alraku Apr 19 '19 at 13:35

1 Answers1

0

I am using JDK.12.0.1 and it works good for me but you should add a JAR file from this website. Add it to your current project.

You have to modify also your module-info.java with requires fontawesomefx. I hope that will helps you.

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40