laobeylu
laobeylu

Reputation: 283

Packaging a Swing application with JavaFX components into an executable JAR

I am having trouble packaging an application with both Swing and JavaFX components into a JAR file. Running it from Eclipse is fine. But when executing the Jar, errors occur: The main method is run, which calls the constructor of my app. The constructor calls a initAndShowGUI() method, which tries to create a JFXPanel for later addition to a JFrame, but fails with following error message: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\User\bin\glass.dll. This library seems to be needed by JavaFX but is somehow not loaded. "Pure" JavaFX apps (without Swing) call something like a "preinitialitation" method for JFX that loads all the needed libs, I think (I'm not completely sure). Also, I've found information on how to deploy Java Web Start apps or applets (http://docs.oracle.com/javafx/2/deployment/deploy_swing_apps.htm), but nothing on "standard" JARs.

Has anybody done this before? I've been looking for a solution a lot but have not been able to find one. Help is highly appreciated!

Upvotes: 2

Views: 1832

Answers (1)

jewelsea
jewelsea

Reputation: 159291

Likely your issue is packaging related.

How did you package the app?

For example:

I know (at least) the last two will work to build a Swing application with JavaFX components into an executable jar.

The SwingInterop sample includes an ant script for packaging the sample into an executable jar. The sample is downloadable from the javafx download site.

I highly recommend reviewing Why should I use the JavaFX ant tasks for packaging my Swing application? which post also includes the source for the SwingInterop sample build file.

Upvotes: 1

Related Questions