10

I am upgrading my IDE to newest versions of netbeans (11.0) and jdk (12.0). When i make a simple basic Web Application With Ant Project, i can't compile it because the output shows following error message:

error: option -Xbootclasspath/p: not allowed with target 12 BUILD FAILED (total time: 1 second)

Obviously Ant script uses this option and jdk 12 does not allow it? But how to fix this??

EDIT: this is the section (build-impl.xml) where the option -Xbootclasspath is used. This is a netbeans generated script. If i remove the option completely, compilation succeeds and application seems to work

<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>
Kaj Risberg
  • 617
  • 9
  • 15
  • -Xbootclasspath/p was for overriding JDK classes defined to the boot loader. The option doesn't make sense with a modular JDK, the replacement is --patch-module to patch modules (which may or may not be mapped to the boot loader). I think it would be useful if you pasted in the part of the ant script that is using -Xbootclasspath/p so there is more context for the question. – Alan Bateman May 24 '19 at 11:59
  • 2
    This issue has been bug reported as [NETBEANS-2452 -Xbootclasspath/p is no longer a supported option](https://issues.apache.org/jira/browse/NETBEANS-2452). Although your answer stated that regression to JDK 8 was your workaround, you may be interested in an alternative approach posted on the *Comments* tab of that bug report which involved editing **build.xml** to use `--patch-module` instead of `-Xbootclasspath/p:`. Obviously that's not an "official" solution, but it would allow you to continue using JDK 11/12 with Ant Builds on NetBeans. (Maven builds are unaffected by this issue.) – skomisa Jul 24 '19 at 00:47

4 Answers4

13

To compile the project on JDK12, simply set empty value to endorsed.classpath= at project.properties file.

Ernestas Gruodis
  • 8,567
  • 14
  • 55
  • 117
  • 2
    Your solution also works for Netbeans 11.2 with JDK 13. – skomisa Nov 28 '19 at 05:28
  • 2
    Your solution also works for Netbeans 12.1 with JDK 15. – Coherence Nov 05 '20 at 08:14
  • Note that with this change, the project sources format must now match the platform java version in project libraries. Otherwise the warning "bootstrap class path not set " appears when compiling – Glucide Aug 31 '22 at 10:41
  • NetBeans 12.6 and JDK 17 and while this solves the problem, re-opening the project repopulates the variable values as: `endorsed.classpath=${libs.JAXB-ENDORSED.classpath}` and the error pops up again. Is there a way to stop NetBeans from reinitialising this var? – Rafs Dec 01 '22 at 13:34
  • @RTD Have you found a solution to get rid of ${libs.JAXB-ENDORSED.classpath} once for all? NetBeans 16 has the same problem. – gouessej Jan 11 '23 at 09:25
  • I moved away from ant and to Gradle with groovy, so basically re-did the building script from scratch. I don't think this is a solution, but I thought I'd invest the time upgrading the build tool entirely. – Rafs Jan 11 '23 at 12:06
3

-Xbootclasspath and -Xbootclasspath/p: (prepend) were removed in JDK9. You can still use -Xbootclasspath/a: to append stuff to the bootstrap class path.

iajn
  • 151
  • 5
  • 1
    Same error with "/a". But when i removed the whole option from build-impl.xml, it started working! Is there a proper way to do this in Netbeans (other than edit build-impl.xml)? – Kaj Risberg May 23 '19 at 10:48
  • This should be a comment rather than an answer. You don't specify how to fix the problem when using NetBeans with JDK 11/12. – skomisa Jul 24 '19 at 01:04
2

I changed the

-Xbootclasspath/p   

to

-J-Xbootclasspath/a

It's working for me.

senanqerib
  • 198
  • 2
  • 5
0

I just noticed that netbeans 11 recommends using JDK 8 with it instead of newer versions. So i'm going back to JDK 8.. ("problem" solved).

Kaj Risberg
  • 617
  • 9
  • 15