Reputation: 65
I am struggling with javac ant task problem for a really long time now. The problem is with that apparently ant is ignoring target attribute which is set to 1.5:
<target name="compile" description="Kompilacja zrodel" depends="init">
<javac target="${compile.targetvm}" source="${compile.sourcecompatibility}" debug="${compile.debug}" optimize="${compile.optimize}" verbose="${compile.verbose}" srcdir="${source.dir}" destdir="${build.classes.dir}" encoding="${compile.source.encoding}" includeantruntime="false">
<classpath refid="compile.classpath" />
</javac>
</target>
The target and source is set to 1.5. When i run the task i have compile error:
foo.Bar is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
According to java docs (link) method createStruct was introduced in java 1.6 so i know that ant is compiling to 1.6 and not to 1.5 as i polite ask him to do.
I was running the task from eclipse and from command line with same result so it's not eclipse problem. I was trying to change the JRE in ANT and to use different ANT versions and nothing helped.
I have tried everything that i could find on web and now i give up. Could someone help me? Pretty please..
Upvotes: 0
Views: 598
Reputation: 159165
Specifying source compatibility only controls the language syntax, not the Java Runtime Library.
Since you haven't told Ant where to find a Java 1.5 Runtime Library, it is using the same library used to invoke Ant.
To fix, specify the bootclasspathref="compile.bootclasspath"
attribute too.
compile.bootclasspath
is defined like this:
<path id="compile.bootclasspath">
<fileset dir="${java15.home}/jre/lib" includes="*.jar"/>
</path>
It should be obvious what java15.home
is. ;-)
Upvotes: 0