So I have this weird problem. Application works within eclipse project, but when I export project to jar. file and run it, then I get IOexception when loading one of fxml files.
Here is the exception:
javafx.fxml.LoadException:
com/root/tomaszm/Countdown.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at com.controller.tomaszm.WrittenNumbersController.initializeStoperAndCountdown(WrittenNumbersController.java:162)
at com.controller.tomaszm.WrittenNumbersController.initialize(WrittenNumbersController.java:114)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at com.model.tomaszm.ChangeTheRoot.initialize(ChangeTheRoot.java:68)
at com.controller.tomaszm.MainRootController.fireUpTheFeature(MainRootController.java:103)
at com.controller.tomaszm.MainRootController.access$0(MainRootController.java:96)
at com.controller.tomaszm.MainRootController$MouseClickListCell$1.handle(MainRootController.java:147)
at com.controller.tomaszm.MainRootController$MouseClickListCell$1.handle(MainRootController.java:1)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
at javafx.scene.Scene$ClickGenerator.access$7900(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/1657033223.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.controller.tomaszm.CountdownController.initialize(CountdownController.java:63)
... 46 more
Tell me if You need some extra informations.
EDIT:
Ive found out that this is a problem with loading the font file that is in source folder Files:
try {
Font registerFont = Font.loadFont(getClass().getClassLoader().getResource("DS-DIGIT.ttf").openStream(), 30);
labTime.setFont(registerFont);
} catch (IOException e1) {
Dialogs.create().title("Exception").masthead(null).message("Couldnt load the font fxml!").showException(e1);
e1.printStackTrace();
}
I just dont get it why this code work within the project and causes some weird errors when I make a jar file. Is there any way I can load this font properly? Btw. I remember in early stages of project that I have build jar file with font in it, and it was working with no problem.... Im counfused here.

DS-DIGIT.ttflocated?