What is the best way to deploy JavaFX application, create JAR and self-contained applications and native installers

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 :

  • Use the javapackager tools that comes with your JDK
  • JavaFX Ant Tasks
  • JavaFX Maven Plugin for a maven project

Self-contained application is one the ways how your application can be packaged and is platform specific. The bundle contains :

  • The application package
  • A private copy of the JRE

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 :

Leave a Comment