I have an ant build for my Java application. I'm forced to make my application be Java 1.6 compatible.
When I run my ant script I get the following warning:
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
Can you explain me what does it mean and what should I do to remove it? The code works fine, but I'm going to put it in production and I don't like to leave this kind of warnings unresolved.
My build.xml file looks like this:
<path id="master-classpath">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile" depends="clean">
<javac srcdir="src" destdir="${bin-dir}" debug="on" source="1.6" includeantruntime="false">
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="clean">
<mkdir dir="${bin-dir}"/>
<mkdir dir="${build-dir}"/>
<delete>
<fileset dir="${bin-dir}"/>
<fileset dir="${build-dir}"/>
</delete>
</target>
Ant version: Ant(TM) version 1.8.2
Java version: javac 1.7.0_79
This means that although you are using
-source
option, you still have JDK 1.7 library, thus javac cannot guarantee that your code will work on Java 1.6. Javac will check whether you are not using new syntactic features (liketry-with-resources
operator), but it cannot check whether you are using new API methods (likejava.nio.file.Files
class). So even if it's compiled correctly, it may not work.To my opinion the best solution is to compile with JDK 1.6. What warning suggests you is to provide the custom bootstrap class path which points on the installed JRE 1.6. So you can follow this advice if you have JRE 1.6, but don't want to run the whole build on JDK 1.6.