【发布时间】:2019-02-09 10:06:30
【问题描述】:
我正在尝试在 Windows 10、Oracle JDK 10.0.2 和 Eclipse Photon 上构建 JavaFX 应用程序。该应用程序有效,如果我将其导出为可执行 jar 它也有效。为了正确构建,我打开“FX Build Configuration”,单击“Generate ant build.xml and run”。 构建失败并出现以下错误:
init-fx-tasks:
[taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found.
do-deploy:
BUILD FAILED
C:\Users\myname\eclipse-workspace\MyProgram\build\build.xml:90: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
浏览论坛我了解问题与运行时/构建环境有关。自动生成的build.xml 状态
<target name="init-fx-tasks">
<path id="fxant">
<filelist>
<file name="${java.home}\..\lib\ant-javafx.jar"/>
<file name="${java.home}\lib\jfxrt.jar"/>
</filelist>
</path>
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpathref="fxant"/>
</target>
我使用安装程序的默认路径安装了 Oracle JDK:C:\Program Files\Java\jdk-10.0.2 和 JRE 以及 C:\Program Files\Java\jre-10.0.2,但在文件系统的任何位置都找不到 build.xml 所需的 jfxrt.jar,而我可以找到 C:\Program Files\Java\jdk-10.0.2\lib\ant-javafx.jar。
在 Eclipse Photon 中,Run->External Tools->External Tools Configuration->JRE 中的“Separate JRE”项被选中并设置为“jdk-10.0.2”。
有人知道如何解决这个问题吗?
非常感谢
【问题讨论】:
-
原因是
${java.home}\..\lib\ant-javafx.jar的路径明显不对。
标签: java eclipse javafx build ant