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
Compile the source file
javac -d . HelloWorldMain.java
Run the javafxpackager command
javafxpackager -createjar -appclass com.java2s.HelloWorldMain -srcdir . -outdir out -outfile helloworld.jar -v
-createjarcreates a JavaFX JAR executable application.
-appclass com.java2s.HelloWorldMainspecifies 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 outsets the destination where the packaged jar file will be created.
-outfile helloworld.jarspecifies the name of the executable jar file.
-vallows 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