JavaFX与Maven [英] JavaFX with Maven

查看:149
本文介绍了JavaFX与Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始了一个JavaFX项目,我想使用Maven作为我的编译器/部署工具。

I recently started a JavaFX project, and I'd like to use Maven as my compiler/deployment tool.

是否有一个很好的教程或插件来集成JavaFX和Maven?

Is there a good tutorial or plugin to integrate JavaFX and Maven?

推荐答案

从Java 7u9开始我认为JavaFX与Java SE运行时一起发布,其余的都是很容易创建一个基于Maven的JavaFX项目。

Starting with Java 7u9 I think JavaFX is shipped together with Java SE runtime and the rest, so it makes it pretty easy to create a Maven-based JavaFX project.

这是你做的(假设你有最新的Java SE 7运行时环境):

Here is what you do (assuming you have latest Java SE 7 runtime environment):


  1. 转到安装JRE库的目录: cd/ c / Program
    Files / Java / jre7 / lib

通过阅读 javafx.properties 文件,查找JavaFX的版本。 cat javafx.properties 将生成如下内容: javafx.runtime.version = 2.2.3

Find what is the version of the JavaFX by reading the javafx.properties file. cat javafx.properties will produce something like: javafx.runtime.version=2.2.3

现在您已准备好将JavaFX运行时包安装到Maven: mvn install:install-file -Dfile = jfxrt.jar -DgroupId = com.oracle - DartifactId = javafx -Dpackaging = jar -Dversion = 2.2.3

Now you are ready to install the JavaFX runtime package to Maven: mvn install:install-file -Dfile=jfxrt.jar -DgroupId=com.oracle -DartifactId=javafx -Dpackaging=jar -Dversion=2.2.3

最后,创建一个简单的Maven项目,比如NetBeans,打开你的pom.xml文件并添加以下依赖项:

Finally, create a simple Maven project, in say NetBeans, open your pom.xml file and add the following dependency:







<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>javafx</artifactId>
  <version>2.2.3</version>
</dependency>






保存pom.xml后,您可以继续使用典型的Maven工作流程。


Once you save the pom.xml you can continue using your typical Maven workflow.

请注意我使用了MSYS( http:// www。 mingw.org )上面的例子中的Windows环境,如果你感到困惑。如果您更喜欢Windows CMD,它将非常相似。没有BASH和GNU工具,比如sed,grep等,我感觉不舒服......

Please note I used the MSYS (http://www.mingw.org) environment on Windows in the examples above in the case you get confused. If you prefer Windows CMD it would be very much similar. I just do not feel comfortable without BASH and GNU tools such as sed, grep, etc...

这篇关于JavaFX与Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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