Search code examples
javaantaxisjavac

Ant javac task errs out: [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6


I'm trying to run an ant task that uses axis2-ant-plugin-1.6.0.jar\org\apache\axis2\tool\ant\AntCodegenTask to perform a WSDL2Java operation.

At the top of the ant script, I define java6.boot.classpath:

    <property name="java6.boot.classpath" value="${env.JAVA6_BOOT_CLASSES}"/>

And I have the JAVA6_BOOT_CLASSES environment variable set to C:\dev\java\64-bit\jdk-1.6.0_45\bin.

The pertinent ant target is as follows:

<!-- dist.jar target -->
<target name="dist.jar" depends="generate"
    description="Creates the web services client jar file">
    <echo>Compiling web services client code</echo>

    <javac srcdir="${project.javapath}" destdir="${build}" 
           source="1.6" target="1.6" 
           debug="true" debuglevel="lines,vars,source" 
           excludes="com/company/junit/**"
           bootclasspath="${java6.boot.classpath}"
           includeantruntime="false">

        <classpath refid="compile.classpath" />
    </javac>

    <echo>Creating ${jarname}.jar</echo>
    <jar destfile="${dist}/${jarname}.jar" basedir="${build}" />
    <echo>${jarname}.jar created</echo>
</target>

Trying to run that, however, I receive the titular error:

 [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6  

Any ideas? I feel like I've appropriately set the boot classpath for Java 1.6, but ant doesn't seem to agree.


Solution

  • This is not Ant but the JDK's javac emitting the warning.

    If you use Java 7's javac and -source for anything smaller than 7 javac warns you you should also set the bootstrap classpath to point to an older rt.jar - because this is the only way to ensure the result is usable on an older VM.

    https://blogs.oracle.com/darcy/entry/bootclasspath_older_source

    This is only a warning, so you could ignore it and even suppress it with

    <compilerarg value="-Xlint:-options"/>
    

    Alternatively you really install an older JVM and adapt your bootclasspath accordingly (you need to include rt.jar, not the bin folder)