【问题标题】:error: option -Xbootclasspath/p: not allowed with target 12 (Netbeans 11.0)错误:选项 -Xbootclasspath/p:目标 12 不允许(Netbeans 11.0)
【发布时间】:2019-09-12 17:50:38
【问题描述】:

我正在将我的 IDE 升级到最新版本的 netbeans (11.0) 和 jdk (12.0)。当我使用 Ant Project 制作一个简单的基本 Web 应用程序时,我无法编译它,因为输出显示以下错误消息:

错误:选项 -Xbootclasspath/p:目标 12 不允许 构建失败(总时间:1 秒)

显然 Ant 脚本使用了这个选项,而 jdk 12 不允许它?但是如何解决这个问题??

编辑:这是使用选项 -Xbootclasspath 的部分 (build-impl.xml)。这是一个 netbeans 生成的脚本。如果我完全删除该选项,编译成功并且应用程序似乎可以工作

<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
    <condition property="have.tests">
        <or>
            <available file="${test.src.dir}"/>
        </or>
    </condition>
    <condition property="have.sources">
        <or>
            <available file="${src.dir}"/>
        </or>
    </condition>
    <condition property="netbeans.home+have.tests">
        <and>
            <isset property="netbeans.home"/>
            <isset property="have.tests"/>
        </and>
    </condition>
    <condition property="no.javadoc.preview">
        <isfalse value="${javadoc.preview}"/>
    </condition>
    <property name="javac.compilerargs" value=""/>
    <condition property="no.deps">
        <and>
            <istrue value="${no.dependencies}"/>
        </and>
    </condition>
    <condition property="no.dist.ear.dir">
        <not>
            <isset property="dist.ear.dir"/>
        </not>
    </condition>
    <property name="build.web.excludes" value="${build.classes.excludes}"/>
    <condition property="do.compile.jsps">
        <istrue value="${compile.jsps}"/>
    </condition>
    <condition property="do.debug.server">
        <or>
            <not>
                <isset property="debug.server"/>
            </not>
            <istrue value="${debug.server}"/>
            <and>
                <not>
                    <istrue value="${debug.server}"/>
                </not>
                <not>
                    <istrue value="${debug.client}"/>
                </not>
            </and>
        </or>
    </condition>
    <condition property="do.debug.client">
        <istrue value="${debug.client}"/>
    </condition>
    <condition property="do.display.browser">
        <istrue value="${display.browser}"/>
    </condition>
    <condition property="do.display.browser.debug.old">
        <and>
            <isset property="do.display.browser"/>
            <not>
                <isset property="do.debug.client"/>
            </not>
            <not>
                <isset property="browser.context"/>
            </not>
        </and>
    </condition>
    <condition property="do.display.browser.debug">
        <and>
            <isset property="do.display.browser"/>
            <not>
                <isset property="do.debug.client"/>
            </not>
            <isset property="browser.context"/>
        </and>
    </condition>
    <available file="${conf.dir}/MANIFEST.MF" property="has.custom.manifest"/>
    <available file="${persistence.xml.dir}/persistence.xml" property="has.persistence.xml"/>
    <condition property="do.war.package.with.custom.manifest">
        <isset property="has.custom.manifest"/>
    </condition>
    <condition property="do.war.package.without.custom.manifest">
        <not>
            <isset property="has.custom.manifest"/>
        </not>
    </condition>
    <condition property="do.tmp.war.package.with.custom.manifest">
        <and>
            <isset property="has.custom.manifest"/>
            <or>
                <isfalse value="${directory.deployment.supported}"/>
                <isset property="dist.ear.dir"/>
            </or>
        </and>
    </condition>
    <condition property="do.tmp.war.package.without.custom.manifest">
        <and>
            <not>
                <isset property="has.custom.manifest"/>
            </not>
            <or>
                <isfalse value="${directory.deployment.supported}"/>
                <isset property="dist.ear.dir"/>
            </or>
        </and>
    </condition>
    <condition property="do.tmp.war.package">
        <or>
            <isfalse value="${directory.deployment.supported}"/>
            <isset property="dist.ear.dir"/>
        </or>
    </condition>
    <property name="build.meta.inf.dir" value="${build.web.dir}/META-INF"/>
    <condition else="" property="application.args.param" value="${application.args}">
        <and>
            <isset property="application.args"/>
            <not>
                <equals arg1="${application.args}" arg2="" trim="true"/>
            </not>
        </and>
    </condition>
    <property name="source.encoding" value="${file.encoding}"/>
    <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
        <and>
            <isset property="javadoc.encoding"/>
            <not>
                <equals arg1="${javadoc.encoding}" arg2=""/>
            </not>
        </and>
    </condition>
    <property name="javadoc.encoding.used" value="${source.encoding}"/>
    <property name="includes" value="**"/>
    <property name="excludes" value=""/>
    <property name="runmain.jvmargs" value=""/>
    <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
    <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
        <and>
            <isset property="endorsed.classpath"/>
            <length length="0" string="${endorsed.classpath}" when="greater"/>
        </and>
    </condition>
    <condition else="false" property="jdkBug6558476">
        <and>
            <matches pattern="1\.[56]" string="${java.specification.version}"/>
            <not>
                <os family="unix"/>
            </not>
        </and>
    </condition>
    <property name="javac.fork" value="${jdkBug6558476}"/>
    <condition property="junit.available">
        <or>
            <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
            <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
        </or>
    </condition>
    <condition property="testng.available">
        <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
    </condition>
    <condition property="junit+testng.available">
        <and>
            <istrue value="${junit.available}"/>
            <istrue value="${testng.available}"/>
        </and>
    </condition>
    <condition else="testng" property="testng.mode" value="mixed">
        <istrue value="${junit+testng.available}"/>
    </condition>
    <condition else="" property="testng.debug.mode" value="-mixed">
        <istrue value="${junit+testng.available}"/>
    </condition>
</target>

【问题讨论】:

  • -Xbootclasspath/p 用于覆盖定义到引导加载程序的 JDK 类。该选项对模块化 JDK 没有意义,替换为 --patch-module 来修补模块(可能映射到也可能不映射到引导加载程序)。我认为如果您粘贴使用 -Xbootclasspath/p 的 ant 脚本部分会很有用,因此该问题有更多上下文。
  • 此问题已报告为NETBEANS-2452 -Xbootclasspath/p is no longer a supported option。尽管您的回答表明回归到 JDK 8 是您的解决方法,但您可能对该错误报告的 Comments 选项卡上发布的另一种方法感兴趣,该方法涉及编辑 build.xml使用--patch-module 而不是-Xbootclasspath/p:。显然,这不是“官方”解决方案,但它允许您继续使用 JDK 11/12 和 NetBeans 上的 Ant Builds。 (Maven 构建不受此问题的影响。)

标签: netbeans ant


【解决方案1】:

要在 JDK12 上编译项目,只需在 project.properties 文件中将 endorsed.classpath= 设置为空值即可。

【讨论】:

  • 您的解决方案也适用于带有 JDK 13 的 Netbeans 11.2。
  • 您的解决方案也适用于带有 JDK 15 的 Netbeans 12.1。
【解决方案2】:

-Xbootclasspath 和 -Xbootclasspath/p:(前置)在 JDK9 中被删除。您仍然可以使用 -Xbootclasspath/a: 将内容附加到引导类路径。

【讨论】:

  • 与“/a”相同的错误。但是当我从 build-impl.xml 中删除整个选项时,它开始工作了!在 Netbeans 中是否有正确的方法来执行此操作(除了编辑 build-impl.xml)?
  • 这应该是评论而不是答案。在使用带有 JDK 11/12 的 NetBeans 时,您没有指定如何解决该问题。
【解决方案3】:

我改了

-Xbootclasspath/p   

-J-Xbootclasspath/a

它对我有用。

【讨论】:

    【解决方案4】:

    我刚刚注意到 netbeans 11 建议使用 JDK 8 而不是较新的版本。所以我要回到JDK 8 ..(“问题”解决了)。

    【讨论】:

    • endorsed.classpath= project.properties 应该可以解决问题。回到 JDK12 :)
    猜你喜欢
    • 1970-01-01
    • 2019-09-22
    • 2019-04-06
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多