Reputation: 34730
I have small Java desktop application without any GUI. I use Ant to dev, run, build and release it. I didn't create a jar file for it. I use a .sh file to launch/run it with the attached JRE in the release.
Now I added a simple JavaFX 2 GUI on top of it. I still can dev, run, build and release with Ant. There is no special target or addition in the Ant file for JavaFX. After release, I cannot run it with the existing .sh file any more. I got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
If I change to launch another entry point without JavaFX involved in the .sh file, it works.
I am pretty sure if I use Swing it will work right way. Why JavaFX is special? Do I have to use Ant or javafxpackager to do special deploy? Any simple way to resolve this? it is a desktop application only.
I am using jdk/jre 1.7.0_51 and on linux.
I am new to JavaFX. don't know if it is worthy to learn it.
Upvotes: 0
Views: 190
Reputation: 206786
When you are using Java 7 or older, then the JavaFX runtime jar file is not in the classpath by default. You need to include it in the classpath.
Add the jar jfxrt.jar
to the classpath; you can find it in the jre\lib
directory of your Java installation.
This will change for Java 8; there, JavaFX will be in the classpath by default and you will not need to add the jar to the classpath yourself.
Upvotes: 3
Reputation: 9872
Make sure that the JRE you include with your app brings in its bundle the JavaFX version you need. A recent version of the JRE should bring it without any problem as explained here:
http://www.oracle.com/technetwork/es/java/javafx/downloads/index.html
Upvotes: 1