making a jar FXJava project

Answered

hello 

so i tried for days now to fix the issue i am having , and still no luck 

i can run the project from the IDE , but when i try to build an executable jar i have alot of errors 

 

i am using gradle and afterburner.fx

i tried with auto-gen ant files but they dont give me a jar file 

 

i tried to make a jar artifact and i get this error 

File: mainboard.fxml not found, attempting with camel case
Cannot load file Mainboard.fxml
Stopping initialization phase...
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Cannot load file Mainboard.fxml
at com.airhacks.afterburner.views.FXMLView.getResourceCamelOrLowerCase(FXMLView.java:221)
at com.airhacks.afterburner.views.FXMLView.getFXMLName(FXMLView.java:205)
at com.airhacks.afterburner.views.FXMLView.<init>(FXMLView.java:83)
at com.airhacks.afterburner.views.FXMLView.<init>(FXMLView.java:72)
at AshesEditor.views.mainboard.MainboardView.<init>(MainboardView.java:8)
at AshesEditor.Main.start(Main.java:31)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application AshesEditor.Main

 

tried gradle build too , assemble and jar 

all of them give me error like this 

error: cannot find symbol
@FXML
^
symbol: class FXML
location: class UnitdetailsPresenter

error: package javafx.fxml does not exist
import javafx.fxml.FXML;

 

basicly with anything related to Javafx even Obserable list 

 

PS , i can run the project from Intelliji 

 

0
6 comments

Do you use the same JDK to run it?

1
Avatar
Permanently deleted user

should be , i am using java 8 

 

maybe i did some progress now i am getting this error 

 

Exception in Application start method
Exception in Application stop method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/airhacks/afterburner/views/FXMLView
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at AshesEditor.Main.start(Main.java:16)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.airhacks.afterburner.views.FXMLView
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 22 more
Exception running application AshesEditor.Main

 

0

Your jar is missing com.airhacks.afterburner.views.FXMLView class (and probably other afterburner classes).

Depending on how you build the jar you should adjust this process so that the main jar includes the dependencies. Google for Gradle jar task configuration options and also check the FatJar Gradle plug-in.

If you are building using IntelliJ IDEA artifact, see http://stackoverflow.com/a/42200519/104891 for details and the sample.

1
Avatar
Permanently deleted user

i checked the file of after burner , and it was there , but its in anotherjar .

0

If it's in another jar, this jar has to be linked via the manifest file classpath, google for details, it's not specific to IntelliJ IDEA.

1
Avatar
Permanently deleted user

i tried moving all the jars inside the main one , and it worked Thanks , 

i will check the FatJar Gradle plug-in.

 

Thanks for the help

0

Please sign in to leave a comment.