JavaFX 11部署失败:无法创建任务或键入javafx:com.sun.javafx.tools.ant:fileset [英] JavaFX 11 Deployment Failure: failed to create task or type javafx:com.sun.javafx.tools.ant:fileset

查看:186
本文介绍了JavaFX 11部署失败:无法创建任务或键入javafx:com.sun.javafx.tools.ant:fileset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署我的项目,但是我仍然收到以下错误,我该怎么办?另外,我具有Java 11,但是在IntelliJ中只能选择高达10的项目语言级别,但是我可以使用"var"变量.语法并运行它. IntelliJ信息:

I am trying to deploy my project but I keep receiving the following errors, what should I do ? Also, I have java 11 but I can only select project language levels up to 10 in IntelliJ, yet I can use "var" syntax and run it. IntelliJ info:

显然intellij IDEA 1.x不支持Java 11我已经下载了最新版本,并且目前正在尝试重做整个版本 处理

Apparently intellij IDEA 1.x does not support java 11 I have downloaded the recent version and currently trying to redo the whole process

最终我已通过在intelliJ IDEA 3.x上使用Java 8解决了该问题,并遵循了 hce

FINAL I have solved the problem by using java 8 on intelliJ IDEA 3.x and followed this guide. Thank you hce!

信息:Java FX打包器:[C:/程序 文件/Java/jdk-11.0.2\bin\java,-Dant.home = D:\ Programs \ IntelliJ IDEA 2018.1.5 \ lib \ ant,-classpath,D:\ Programs \ IntelliJ IDEA 2018.1.5 \ lib \ ant/lib/ant.jar; D:\ Programs \ IntelliJ IDEA 2018.1.5 \ lib \ ant/lib/ant -launcher.jar; C:/程序文件/Java/jdk-11.0.2/lib/ant-javafx.jar;C:/程序 文件/Java/jdk-11.0.2/jre/lib/jfxrt.jar, org.apache.tools.ant.launch.Launcher,-f, C:\ Users \ HP.IntelliJIdea2018.1 \ system \ compile-server \ luckypick-m_8a6db982_temp_ \ build.xml] 信息:Java FX Packager:构建文件: C:\ Users \ HP.IntelliJIdea2018.1 \ system \ compile-server \ luckypick-m_8a6db982_temp_ \ build.xml 信息:Java FX打包器:[taskdef]无法加载定义 来自资源com/sun/javafx/tools/ant/antlib.xml.不可能是 成立.信息:Java FX打包器:信息:Java FX打包器: 构建工件:信息:27.01.2019 15:09-编译完成 在8 s 226 ms中出现2个错误和0个警告错误:Java FX Packager: 建立失败 C:\ Users \ HP.IntelliJIdea2018.1 \ system \ compile-server \ luckypick-m_8a6db982_temp_ \ build.xml:3: 问题:无法创建任务或类型 javafx:com.sun.javafx.tools.ant:fileset原因:名称未定义. 行动:检查拼写.行动:检查是否有任何自定义任务/类型 已经被宣布.行动:检查是否/ 声明已经发生.尚未定义任何类型或任务 此名称空间尚未总时间:0秒错误:Java FX Packager: fx:部署任务失败.

Information:Java FX Packager: [C:/Program Files/Java/jdk-11.0.2\bin\java, -Dant.home=D:\Programs\IntelliJ IDEA 2018.1.5\lib\ant, -classpath, D:\Programs\IntelliJ IDEA 2018.1.5\lib\ant/lib/ant.jar;D:\Programs\IntelliJ IDEA 2018.1.5\lib\ant/lib/ant-launcher.jar;C:/Program Files/Java/jdk-11.0.2/lib/ant-javafx.jar;C:/Program Files/Java/jdk-11.0.2/jre/lib/jfxrt.jar, org.apache.tools.ant.launch.Launcher, -f, C:\Users\HP.IntelliJIdea2018.1\system\compile-server\luckypick-m_8a6db982_temp_\build.xml] Information:Java FX Packager: Buildfile: C:\Users\HP.IntelliJIdea2018.1\system\compile-server\luckypick-m_8a6db982_temp_\build.xml Information:Java FX Packager: [taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found. Information:Java FX Packager: Information:Java FX Packager: build artifact: Information:27.01.2019 15:09 - Compilation completed with 2 errors and 0 warnings in 8 s 226 ms Error:Java FX Packager: BUILD FAILED C:\Users\HP.IntelliJIdea2018.1\system\compile-server\luckypick-m_8a6db982_temp_\build.xml:3: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:fileset Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any / declarations have taken place. No types or tasks have been defined in this namespace yet Total time: 0 seconds Error:Java FX Packager: fx:deploy task has failed.

这是我的项目目录的外观以及它包含的文件.

Here is how my project directory looks and which files it has.

这是luckypick.properties

Here's luckypick.properties

path.variable.kotl\u0131n_bundled=D\:\\Programs\\IntelliJ IDEA 2018.1.5\\plugins\\Kotlin\\kotlinc
path.variable.maven_repos\u0131tory=C\:\\Users\\HP\\.m2\\repository
jdk.home.11=C\:/Program Files/Java/jdk-11.0.2
idea.home=D\:/Programs/IntelliJ IDEA 2018.1.5
javafx.home=C\:/Users/HP/Documents/javafx-sdk-11.0.2
javac2.instrumentation.includeJavaRuntime=false

这是luckypick.xml

Here's luckypick.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="luckypick" default="all">


    <property file="luckypick.properties"/>
    <!-- Uncomment the following property if no tests compilation is needed -->
    <!--
    <property name="skip.tests" value="true"/>
     -->

    <!-- Compiler options -->

    <property name="compiler.debug" value="on"/>
    <property name="compiler.generate.no.warnings" value="off"/>
    <property name="compiler.args" value=""/>
    <property name="compiler.max.memory" value="700m"/>
    <patternset id="ignored.files">
        <exclude name="**/*.hprof/**"/>
        <exclude name="**/*.pyc/**"/>
        <exclude name="**/*.pyo/**"/>
        <exclude name="**/*.rbc/**"/>
        <exclude name="**/*.yarb/**"/>
        <exclude name="**/*~/**"/>
        <exclude name="**/.DS_Store/**"/>
        <exclude name="**/.git/**"/>
        <exclude name="**/.hg/**"/>
        <exclude name="**/.svn/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/__pycache__/**"/>
        <exclude name="**/_svn/**"/>
        <exclude name="**/vssver.scc/**"/>
        <exclude name="**/vssver2.scc/**"/>
    </patternset>
    <patternset id="library.patterns">
        <include name="*.egg"/>
        <include name="*.jar"/>
        <include name="*.ear"/>
        <include name="*.swc"/>
        <include name="*.war"/>
        <include name="*.zip"/>
        <include name="*.ane"/>
    </patternset>
    <patternset id="compiler.resources">
        <exclude name="**/?*.java"/>
        <exclude name="**/?*.form"/>
        <exclude name="**/?*.class"/>
        <exclude name="**/?*.groovy"/>
        <exclude name="**/?*.scala"/>
        <exclude name="**/?*.flex"/>
        <exclude name="**/?*.kt"/>
        <exclude name="**/?*.clj"/>
    </patternset>

    <!-- JDK definitions -->

    <property name="jdk.bin.11" value="${jdk.home.11}/bin"/>
    <path id="jdk.classpath.11">
        <fileset dir="${jdk.home.11}">
            <include name="/legal/java.base"/>
            <include name="/legal/java.compiler"/>
            <include name="/legal/java.datatransfer"/>
            <include name="/legal/java.desktop"/>
            <include name="/legal/java.instrument"/>
            <include name="/legal/java.logging"/>
            <include name="/legal/java.management"/>
            <include name="/legal/java.management.rmi"/>
            <include name="/legal/java.naming"/>
            <include name="/legal/java.net.http"/>
            <include name="/legal/java.prefs"/>
            <include name="/legal/java.rmi"/>
            <include name="/legal/java.scripting"/>
            <include name="/legal/java.se"/>
            <include name="/legal/java.security.jgss"/>
            <include name="/legal/java.security.sasl"/>
            <include name="/legal/java.smartcardio"/>
            <include name="/legal/java.sql"/>
            <include name="/legal/java.sql.rowset"/>
            <include name="/legal/java.transaction.xa"/>
            <include name="/legal/java.xml"/>
            <include name="/legal/java.xml.crypto"/>
            <include name="/legal/jdk.accessibility"/>
            <include name="/legal/jdk.aot"/>
            <include name="/legal/jdk.attach"/>
            <include name="/legal/jdk.charsets"/>
            <include name="/legal/jdk.compiler"/>
            <include name="/legal/jdk.crypto.cryptoki"/>
            <include name="/legal/jdk.crypto.ec"/>
            <include name="/legal/jdk.crypto.mscapi"/>
            <include name="/legal/jdk.dynalink"/>
            <include name="/legal/jdk.editpad"/>
            <include name="/legal/jdk.hotspot.agent"/>
            <include name="/legal/jdk.httpserver"/>
            <include name="/legal/jdk.internal.ed"/>
            <include name="/legal/jdk.internal.jvmstat"/>
            <include name="/legal/jdk.internal.le"/>
            <include name="/legal/jdk.internal.opt"/>
            <include name="/legal/jdk.internal.vm.ci"/>
            <include name="/legal/jdk.internal.vm.compiler"/>
            <include name="/legal/jdk.internal.vm.compiler.management"/>
            <include name="/legal/jdk.jartool"/>
            <include name="/legal/jdk.javadoc"/>
            <include name="/legal/jdk.jcmd"/>
            <include name="/legal/jdk.jconsole"/>
            <include name="/legal/jdk.jdeps"/>
            <include name="/legal/jdk.jdi"/>
            <include name="/legal/jdk.jdwp.agent"/>
            <include name="/legal/jdk.jfr"/>
            <include name="/legal/jdk.jlink"/>
            <include name="/legal/jdk.jshell"/>
            <include name="/legal/jdk.jsobject"/>
            <include name="/legal/jdk.jstatd"/>
            <include name="/legal/jdk.localedata"/>
            <include name="/legal/jdk.management"/>
            <include name="/legal/jdk.management.agent"/>
            <include name="/legal/jdk.management.jfr"/>
            <include name="/legal/jdk.naming.dns"/>
            <include name="/legal/jdk.naming.rmi"/>
            <include name="/legal/jdk.net"/>
            <include name="/legal/jdk.pack"/>
            <include name="/legal/jdk.rmic"/>
            <include name="/legal/jdk.scripting.nashorn"/>
            <include name="/legal/jdk.scripting.nashorn.shell"/>
            <include name="/legal/jdk.sctp"/>
            <include name="/legal/jdk.security.auth"/>
            <include name="/legal/jdk.security.jgss"/>
            <include name="/legal/jdk.unsupported"/>
            <include name="/legal/jdk.unsupported.desktop"/>
            <include name="/legal/jdk.xml.dom"/>
            <include name="/legal/jdk.zipfs"/>
        </fileset>
    </path>

    <property name="project.jdk.home" value="${jdk.home.11}"/>
    <property name="project.jdk.bin" value="${jdk.bin.11}"/>
    <property name="project.jdk.classpath" value="jdk.classpath.11"/>


    <!-- Project Libraries -->

    <path id="library.javafx-swt.classpath">
        <pathelement location="${javafx.home}/lib/javafx-swt.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.base.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.controls.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.fxml.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.graphics.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.media.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.swing.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.web.jar"/>
    </path>


    <!-- Global Libraries -->
    <!-- Register Custom Compiler Taskdefs -->
    <property name="javac2.home" value="${idea.home}/lib"/>
    <path id="javac2.classpath">
        <fileset dir="${javac2.home}">
            <include name="javac2.jar"/>
            <include name="jdom.jar"/>
            <include name="asm-all*.jar"/>
            <include name="jgoodies-forms.jar"/>
        </fileset>
    </path>
    <target name="register.custom.compilers">
        <taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
        <taskdef name="instrumentIdeaExtensions" classname="com.intellij.ant.InstrumentIdeaExtensions"
                 classpathref="javac2.classpath"/>
    </target>

    <!-- Modules -->


    <!-- Module LuckyPick -->

    <dirname property="module.luckypick.basedir" file="${ant.file}"/>


    <property name="module.jdk.home.luckypick" value="${project.jdk.home}"/>
    <property name="module.jdk.bin.luckypick" value="${project.jdk.bin}"/>
    <property name="module.jdk.classpath.luckypick" value="${project.jdk.classpath}"/>

    <property name="compiler.args.luckypick" value="-encoding UTF-8 -source 10 -target 10 ${compiler.args}"/>

    <property name="luckypick.output.dir" value="${module.luckypick.basedir}/out/production/LuckyPick"/>
    <property name="luckypick.testoutput.dir" value="${module.luckypick.basedir}/out/test/LuckyPick"/>

    <path id="luckypick.module.bootclasspath">
        <!-- Paths to be included in compilation bootclasspath -->
    </path>

    <path id="luckypick.module.production.classpath">
        <path refid="${module.jdk.classpath.luckypick}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.runtime.production.module.classpath">
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.module.classpath">
        <path refid="${module.jdk.classpath.luckypick}"/>
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.runtime.module.classpath">
        <pathelement location="${luckypick.testoutput.dir}"/>
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>


    <patternset id="excluded.from.module.luckypick">
        <patternset refid="ignored.files"/>
    </patternset>

    <patternset id="excluded.from.compilation.luckypick">
        <patternset refid="excluded.from.module.luckypick"/>
    </patternset>

    <path id="luckypick.module.sourcepath">
        <dirset dir="${module.luckypick.basedir}">
            <include name="src"/>
            <include name="res"/>
        </dirset>
    </path>


    <target name="compile.module.luckypick" depends="compile.module.luckypick.production,compile.module.luckypick.tests"
            description="Compile module LuckyPick"/>

    <target name="compile.module.luckypick.production" depends="register.custom.compilers"
            description="Compile module LuckyPick; production classes">
        <mkdir dir="${luckypick.output.dir}"/>
        <javac2 destdir="${luckypick.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}"
                memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.luckypick}/javac">
            <compilerarg line="${compiler.args.luckypick}"/>
            <bootclasspath refid="luckypick.module.bootclasspath"/>
            <classpath refid="luckypick.module.production.classpath"/>
            <src refid="luckypick.module.sourcepath"/>
            <patternset refid="excluded.from.compilation.luckypick"/>
        </javac2>

        <copy todir="${luckypick.output.dir}">
            <fileset dir="${module.luckypick.basedir}/src">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
            <fileset dir="${module.luckypick.basedir}/res">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
        </copy>
    </target>

    <target name="compile.module.luckypick.tests"
            depends="register.custom.compilers,compile.module.luckypick.production"
            description="compile module LuckyPick; test classes" unless="skip.tests"/>

    <target name="clean.module.luckypick" description="cleanup module">
        <delete dir="${luckypick.output.dir}"/>
        <delete dir="${luckypick.testoutput.dir}"/>
    </target>

    <target name="init" description="Build initialization">
        <!-- Perform any build initialization in this target -->
    </target>

    <target name="clean" depends="clean.module.luckypick" description="cleanup all"/>

    <target name="build.modules" depends="init, clean, compile.module.luckypick" description="build all modules"/>

    <target name="all" depends="build.modules" description="build all"/>
</project>

ant build输出:

ant build output:

推荐答案

请.尝试以下操作:

<project name="luckypick" default="all" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
...
<target name="all" depends="build.modules" description="build all">
   <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
            uri="javafx:com.sun.javafx.tools.ant"
            classpath=".:path/to/sdk/lib/ant-javafx.jar"/>    
</target>

也尝试使用JDK8.从Oracle JDK 11中删除了Packager. 有关详细信息,请参见此处

Also try to use JDK 8. The Packager is removed from Oracle JDK 11. See here for Details

包装工具还可以帮助填补其他技术留下的空白 例如从Oracle的JDK 11中删除的Java Web Start,以及 pack200,在JDK 11中已弃用,以后会删除 释放.开发人员可以使用jlink将JDK精简到最小 所需的一组模块,然后使用打包工具 产生一个压缩的,可安装的映像,该映像可以部署到目标 机器.

A packaging tool can also help fill gaps left by other technologies such as Java Web Start, which was removed from Oracle’s JDK 11, and pack200, which was deprecated in JDK 11 for removal in a future release. Developers can use jlink to strip the JDK down to the minimal set of modules that are needed, and then use the packaging tool to produce a compressed, installable image that can be deployed to target machines.

为解决以前的这些要求,使用了一个打包工具 javapackager与Oracle的JDK 8一起分发. 从Oracle JDK 11中删除,与删除JavaFX有关.

To address these requirements previously, a packaging tool called javapackager was distributed with Oracle’s JDK 8. However, it was removed from Oracle’s JDK 11 in connection with the removal of JavaFX.

这篇关于JavaFX 11部署失败:无法创建任务或键入javafx:com.sun.javafx.tools.ant:fileset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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