Exporting Jar file in Eclipse using JavaFX


I have created an app using JavaFX 2.1 and wish to export it to be tested. This is the first "real" application I've made, so I have never done this before. In Windows 7 with eclipse I export a runnable jar, click on it, and nothing happens. Can someone tell me why this might be?

6/23/2012 6:37:13 PM

Accepted Answer

Information on Packaging

The app below was packaged using the command line javafxpackager tool. JavaFX also provides ant tasks for packaging. I believe you could create an ant script for packaging and run it's tasks from inside Eclipse.

The e(fx)clipse plugin provides integrated JavaFX packaging functionality by wrapping the JavaFX ant tasks. When developing JavaFX applications with Eclipse, use of e(fx)clipse is highly recommended.

Verifying your JavaFX Packaging

  • Extract the jar files from the jar (jar xf <jarfile>).
  • Look at the extracted manifest (META-INF\MANIFEST.MF).
  • If the main class in the manifest is not com/javafx/main/Main then you have packaged the app wrong.

C:\dev\javafx\willow\dist>jar xf willow.jar

C:\dev\javafx\willow\dist>type MANIFEST.MF
Manifest-Version: 1.0
JavaFX-Version: 2.1
JavaFX-Application-Class: org.jewelsea.willow.Willow
JavaFX-Class-Path: lib\image4j.jar lib\PDFRenderer-0.9.1.jar
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main

C:\dev\javafx\willow\dist>java -jar willow.jar

For your manifest the JavaFX-Application-Class entry will vary and the JavaFX-Class-Path attribute is probably not needed.

The example jar I used can then be run from the command line using java -jar <jarfile>.

10/22/2012 7:10:47 PM

Like mentioned by the jewelsea e(fx)clipse provides you an export wizard which uses the ant tasks provided by JavaFX. You can find a step by step tutorial at https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial1

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow