JavaFX Tutorial - JavaFX Package

To distribute or deploy JavaFX application we need to package the JavaFX application class.

To handle the application packaging and deployment, we can use JavaFX Packager tool to build, package, and deploy applications.

The following steps shows how to use the JavaFX Packager tools.

Go to the source folder as follows

cd com/java2s

Compile the source file

javac -d  .

Run the javafxpackager command

javafxpackager -createjar -appclass com.java2s.HelloWorldMain -srcdir . -outdir  out
-outfile  helloworld.jar -v
  • -createjar creates a JavaFX JAR executable application.
  • -appclass com.java2s.HelloWorldMain specifies the fully qualified name of the class containing the main() method.
  • -srcdir . sets the top-level location of the parent directory holding the compiled classes (current directory).
  • -outdir out sets the destination where the packaged jar file will be created.
  • -outfile helloworld.jar specifies the name of the executable jar file.
  • -v allows verbose displays logging information when executing javafxpackager.

To run the jar executable on the command line, type the following and press Enter:

javaw  -jar out/helloworld.jar