简体   繁体   English

JavaFX Ant构建失败,JDK 10.0.2 Eclipse Photon

[英]JavaFX Ant build failed, JDK 10.0.2 Eclipse Photon

I am trying to build a JavaFX application on Windows 10, Oracle JDK 10.0.2 and Eclipse Photon. 我正在尝试在Windows 10,Oracle JDK 10.0.2和Eclipse Photon上构建JavaFX应用程序。 The application works, also if I export it as an executable jar it works. 该应用程序可以正常工作,如果我将其导出为可执行jar的话,它也可以工作。 For a proper build, I open the "FX Build Configuration", click on "Generate ant build.xml and run". 为了进行正确的构建,我打开“ FX Build Configuration”,单击“ Generate ant build.xml and run”。 The build fails with the following error: 构建失败,并出现以下错误:

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

Browsing the forum I understand the problem is related to the runtime/build environment. 浏览论坛,我知道问题与运行时/构建环境有关。 The automatically generated build.xml states 自动生成的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>

I installed Oracle JDK with intaller's default paths: C:\\Program Files\\Java\\jdk-10.0.2 and JRE as well C:\\Program Files\\Java\\jre-10.0.2 , but cannot find the jfxrt.jar required by build.xml in any place in the filesystem, while I can locate C:\\Program Files\\Java\\jdk-10.0.2\\lib\\ant-javafx.jar . 我安装了Oracle JDK与intaller的默认路径: C:\\Program Files\\Java\\jdk-10.0.2和JRE以及C:\\Program Files\\Java\\jre-10.0.2 ,但找不到jfxrt.jar所要求的build.xml在文件系统中的任何位置,而我可以找到C:\\Program Files\\Java\\jdk-10.0.2\\lib\\ant-javafx.jar

In Eclipse Photon, in Run->External Tools->External Tools Configuration->JRE the item "Separate JRE" is selected and set to "jdk-10.0.2". 在Eclipse Photon中,在“ Run->External Tools->External Tools Configuration->JRE “ JRE”中,选择了“ Separate JRE”项并将其设置为“ jdk-10.0.2”。 Does anybody have clue of how to solve this? 有人知道如何解决这个问题吗? Many thanks 非常感谢

This might be a bit late, but I don't see answers and it was a bit of a pain to troubleshoot for my own project. 这可能会有点晚,但是我看不到答案,因此无法为自己的项目进行故障排除。 This tutorial has most of the right steps https://code.makery.ch/library/javafx-tutorial/part7/ , however it comes down to then fixing a few things, like where your ${java.home} variable points to, mine pointed to: 本教程具有大多数正确的步骤https://code.makery.ch/library/javafx-tutorial/part7/ ,但是它可以解决一些问题,例如$ {java.home}变量指向的位置,我的指出:

C:\\Program Files\\Java\\jre1.8.0_191 C:\\ Program Files \\ Java \\ jre1.8.0_191

What this means is the jfxrt.jar and ant-javafx.jar cannot be found on those locations, so I changed them to the following: 这意味着在这些位置上找不到jfxrt.jar和ant-javafx.jar,因此我将其更改为以下内容:

<filelist>
  <file name="${java.home}\..\jdk1.8.0_191\lib\ant-javafx.jar"/>
  <file name="${java.home}\lib\ext\jfxrt.jar"/>
  <file name="${basedir}"/>
</filelist>

This works since I have both JRE and the JDK on my work work computer. 因为我在工作工作计算机上同时拥有JRE和JDK,所以此方法可行。 Also make sure you have E(fx)clipse installed. 另外,请确保已安装E(fx)clipse。 If you had resource files, custom images and so make sure that the deployment structure matches your project. 如果您有资源文件,自定义映像,请确保部署结构与您的项目匹配。 I usually create a deploy folder on the root of my project and copy the from the dist folder generated by the build.xml. 通常,我通常在项目的根目录上创建一个deploy文件夹,然后从build.xml生成的dist文件夹中复制。 It can be automated, but I would not worry about it until you can successfully make a deployment... then automate small parts until you have a well working system (just my two cents for what is worth). 它可以是自动化的,但是在您成功进行部署之前,我不会担心它。然后自动执行小部件,直到您有一个运行良好的系统(仅花两分钱就可以得到)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM