JavaFX教程 – JavaFX包
要分发或部署JavaFX应用程序,我们需要打包JavaFX应用程序类。
要处理应用程序打包和部署,我们可以使用JavaFX Packager工具来构建,打包和部署应用程序。
以下步骤显示如何使用JavaFX Packager工具。
转到源文件夹如下
cd com/w3cschool
编译源文件
javac -d . HelloWorldMain.java
运行javafxpackager命令
javafxpackager -createjar -appclass com.w3cschool.HelloWorldMain -srcdir . -outdir out -outfile helloworld.jar -v
-
-createjar
creates a JavaFX JAR executable application. -
-appclass com.w3cschool.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.
要在命令行上运行jar可执行文件,请键入以下内容并按Enter键:
javaw -jar out/helloworld.jar