且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JavaFX在Eclipse中导出Jar文件

更新时间:2021-07-15 01:28:02

包装信息

下面的应用程序是使用命令行 javafxpackager打包的工具。 JavaFX还提供 ant任务以进行打包。我相信你可以创建一个用于打包的ant脚本,并从Eclipse内部运行它的任务。

The app below was packaged using the command line javafxpackager tool. JavaFX also provides ant tasks for packaging. I believe you could create an ant script for packaging and run it's tasks from inside Eclipse.

e(fx)clipse 插件通过包装JavaFX ant任务提供集成的JavaFX打包功能。使用Eclipse开发JavaFX应用程序时,强烈建议使用e(fx)clipse。

The e(fx)clipse plugin provides integrated JavaFX packaging functionality by wrapping the JavaFX ant tasks. When developing JavaFX applications with Eclipse, use of e(fx)clipse is highly recommended.

验证JavaFX包装


  • 从jar中提取jar文件( jar xf< jarfile> )。

  • 查看提取的清单( META-INF \ MANIFEST.MF )。

  • 如果是主类在清单中不是com / javafx / main / Main然后你打包了应用程序错误。

  • Extract the jar files from the jar (jar xf <jarfile>).
  • Look at the extracted manifest (META-INF\MANIFEST.MF).
  • If the main class in the manifest is not com/javafx/main/Main then you have packaged the app wrong.
C:\dev\javafx\willow\dist>jar xf willow.jar

C:\dev\javafx\willow\dist>type MANIFEST.MF
Manifest-Version: 1.0
JavaFX-Version: 2.1
JavaFX-Application-Class: org.jewelsea.willow.Willow
JavaFX-Class-Path: lib\image4j.jar lib\PDFRenderer-0.9.1.jar
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main

C:\dev\javafx\willow\dist>java -jar willow.jar

对于您的清单 JavaFX-Application-Class 条目会有所不同,可能不需要 JavaFX-Class-Path 属性。

For your manifest the JavaFX-Application-Class entry will vary and the JavaFX-Class-Path attribute is probably not needed.

然后我可以使用 java -jar< jarfile> 从命令行运行我使用的示例jar。

The example jar I used can then be run from the command line using java -jar <jarfile>.