使用JavaFX在Eclipse中导出Jar文件 [英] Exporting Jar file in Eclipse using JavaFX

查看:1664
本文介绍了使用JavaFX在Eclipse中导出Jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JavaFX 2.1创建了一个应用程序,并希望将其导出以进行测试。这是我做的第一个真正的应用程序,所以我以前从未这样做过。在带有eclipse的Windows 7中,我导出了一个可运行的jar,点击它,没有任何反应。有人可以告诉我为什么会这样吗?

I have created an app using JavaFX 2.1 and wish to export it to be tested. This is the first "real" application I've made, so I have never done this before. In Windows 7 with eclipse I export a runnable jar, click on it, and nothing happens. Can someone tell me why this might be?

推荐答案

包装信息

下面的应用程序是使用命令行 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>.

这篇关于使用JavaFX在Eclipse中导出Jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆