I have javaFX project, with which i'm working on Eclipse IDE. This is Maven project with using of Spring. My goal is to make runable jar file (dekstop application) from this project.
If i export my application to jar file like any other java project, then i recieve this on error:
C:\eclipse\projjars>java -jar EqMan.jar
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: C:\eclipse\bin\glass.dll
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:276)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:122)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:163)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\eclipse\bin\glass.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:143)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:56)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:31)
at com.sun.glass.ui.Application$1.run(Application.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:73)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:85)
at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:20)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:17)
at com.sun.glass.ui.Application.Run(Application.java:108)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:266)
... 5 more
If i'm trying to make jar file with javafxpackager, i recieve this one error:
C:\eclipse\workspace\equification>javafxpackager -makeall -appclass ru.igs.ava.equification.EquificationFX -name "Equification" -width 800 -height 600
warning: [options] bootstrap class path not set in conjunction with -source 1.5
C:\eclipse\workspace\equification\src\main\java\ru\igs\ava\equification\EqConfigureRole.java:5: error: package org.springframework.context does not exist
import org.springframework.context.ApplicationContext;
C:\eclipse\workspace\equification\src\test\java\ru\igs\ava\equification\AppTest.java:11: error: cannot find symbol
extends TestCase
^
//and the same error for every class, which is added to my project as maven dependency.
So, how can i make runable jar file without converting my project to NetBeans project?
To create an executable jar, press ctrl + shift + alt + s or go to file -> project structure. Select Artifacts. 2. Click on + button and select JAR and click on From modules with dependencies.
Seeing as you are using Maven for your builds, you can also use Maven to initiate the JavaFX packaging. To do this use the Maven antrun plugin to invoke the JavaFX ant tasks to generate a jar for your application with an embedded JavaFX launcher. Here is a sample maven pom to do this.
Your errors in running the javafx packager are due to not appropriately setting the classpath for the packager. An example of how to set the classpath for the javafx packager to package an application which relies on dependent lib jars is in this build script.
The unsatisfied link errors are because you are not including the required lib dll's in a ../bin directory relative to the runtime location of jfxrt.jar when you run your app. You also might not be correctly packaging your application with a JavaFX launcher (via executing the recommended javafx ant tasks or javafxpackager commands to generate your JavaFX application jar).
Update
For Maven based builds of JavaFX applications, you can now use a Maven JavaFX plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With