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

元气小坏坏 提交于 2019-12-22 05:53:37

问题


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.


回答1:


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)




回答2:


In the ant build.xml file create a property which will point to Java 6 rt.jar

<path id="boot.classpath" location="C:/Program Files (x86)/Java/jre6/lib/rt.jar" />

and refer to it in the javac task:

<javac srcdir="${src}" bootclasspathref="boot.classpath" classpathref="classpath" includeantruntime="false" destdir="${build}" source="1.6" target="1.6" />

You may also directly specify the bootclasspath in javac task using bootclasspath attribute




回答3:


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

This is the problem. Set the bootclasspath to point to the directory that contains the rt.jar. It should be like: C:\dev\java\64-bit\jdk-1.6.0_45\jre\lib



来源:https://stackoverflow.com/questions/28287383/ant-javac-task-errs-out-javac-warning-options-bootstrap-class-path-not-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!