I'm using IntelliJ IDEA, and I have my JavaFX application ready for deployment. The problem is that when I generate the JAR file, it won't run, when I run it in the command line, I get an Exception, FXMLLoadException, although the project is working perfectly in my IDE.
Ant tasks end with errors, after 15 minutes of building, I really don't understand what's the problem exactly.
So my question what are the right steps to deploy a JavaFX application the right way, any tutorial or guide will be welcome.
A Java application can be packaged in various ways. Please go through Java Packaging Overview to find everything about it. One of the packaging is a self-contained Java application
.
There are different ways to create these packages :
javapackager
tools that comes with your JDKSelf-contained application is one the ways how your application can be packaged and is platform specific. The bundle contains :
A list of available bundles can be found here.
Let us check out the various tools available at our disposal and how to use them:
JavaPackager Tool
JavaPackager Tool is the most basic tool and helps you to compile, package, sign, and deploy your Java(FX) applications, without writing any additional scripts. The javapackager.jar
file is located in the bin directory of the JDK installation.
The list of commands, that can be used with it is available here.
JavaFX Ant Tasks
JavaFX Ant Tasks helps you package your application by just creating a build.xml
file for your project.
A set of examples on how to use ant scripts for your project can be found here.
The list of commands that can be used for with it is available here.
JavaFX Maven Plugin
JavaFX Maven Plugin leverages the usage of packaging java application to the maven platform. You can use it to package your maven based java application by adding a plugin to the project.
This plugin IMHO, if the easiest
to use out of the three. It is a very nicely written, easy to understand tool and has extensive documentation.
JavaFX Gradle Plugin
JavaFX Gradle Plugin is also from the author of the maven plugin. It has all the features that the maven plugin has, but for Gradle :)
Further Reading :
Oracle has an extensive guide about packaging on their website for JavaFX 2 and for JavaFX 8.
If you need help for your specific problem, post the code and the stacktrace of the error you get.
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