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.
The UnsupportedClassVersionError is a sub-class of the LinkageError and thrown by the Java Virtual Machine (JVM). When a class file is read and when major and minor version numbers are not supported, this error is thrown, and especially during the linking phase, this error is thrown.
minor version error is thrown in Java when a class is compiled using a higher version of the Java Development Kit (JDK) but executed on a lower version of the Java Runtime Environment (JRE). The exact cause is printed on the version e.g. in the case of major.
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\
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With