小智 18
这是一个可能的解决方案.
lib在项目目录中创建一个文件夹,并将jfxrt.jar放入该目录中.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.2.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jfxrt.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果你想构建一个可执行jar,你只需要包含javafx-maven-plugin.有关详细信息,请参阅:link-to-github
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<mainClass>[put your application main class here]</mainClass>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
est*_*edi 12
不,暂时不存在这样的解决方案.我怀疑它会永远,因为从Java 1.7更新2开始,JavaFX与JVM一起安装.计划从Java 1.8(明年)开始在JRE中包含JavaFX.从那时起,您根本不需要依赖.
但是你现在已经可以使用Maven和JavaFX,因为Maven可以调用Ant任务(antrun插件),并且JavaFX发行版提供了超级Ant任务.我在博客上写了这篇文章,但它是用法语写的:Creer un projet Maven pour JavaFX2.它将引导您完成整个过程.不过,如果您不懂法语,请对文章发表评论,我会尽力帮助您或在Oracle论坛中查看
谢尔盖的文章建议将javafx添加为系统依赖,不应该使用它.相反,您可以在POM中包含以下内容以自动安装javafx.
<profile>
<id>install-javafx</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-javafx</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<file>${jfx-runtime}/lib/jfxrt.jar</file>
<groupId>javafx</groupId>
<artifactId>javafx</artifactId>
<version>${jfx-version}</version>
<packaging>jar</packaging>
<javadoc>${jfx-runtime}/../docs/api.zip</javadoc>
<!--<sources>no source available</sources>-->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>install-javafx-bin</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${settings.localRepository}/javafx/javafx</outputDirectory>
<useBuildFilters>false</useBuildFilters>
<resources>
<resource>
<directory>${jfx-runtime}</directory>
<includes>
<include>bin/*.dll</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
如果要安装api文档,请将docs/api文件夹的内容压缩到docs/api.zip.现在你只需运行maven,激活配置文件并设置jfx-runtime和jfx-version属性.
| 归档时间: |
|
| 查看次数: |
79533 次 |
| 最近记录: |