I'm running this target in Ant.
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
It's giving me this error.
C:\Users\..\workspace\..\build.xml:21: java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 51.0
Here are the versions:
Apache Ant(TM) version 1.8.2
JDK version is JDK 1.7.0
Here's my Compiler settings in Eclipse.
Please help me resolve it.
Check if tools.jar used during compilation complies with the JRE set. If you are on eclipse, verify the versions as:
Goto Window->Preferences
- Check Ant Runtime by selecting Runtime under Ant in the left pane. Check the Global Entries under classpath tab. You can see the version in folder path.
- On the left pane check installed JREs under Java. Check the version.
I had also got the same problem when my selected JRE was 1.6.0_24 and tools.jar in Ant runtime was coming from jdk 1.7
If both of them are from different versions- 1.6/1.7, correct them by correcting their path.
Typically, tools.jar can be found at :C:\Program Files\Java\jdk1.x.x\lib. Likewise if required add the JRE by pointing it to C:\Program Files\Java\jdk1.x.x\