Unsupported major.minor version 51.0 Error With Eclipse When Trying to
Reference Jar File
I have a simple java sandbox project which I reference the code for
Xerces-For-Android. If I put the source code directly into the project,
I'm able to compile and run my test program successfully. However if I
make a jar file, then add that into my build path I get the Unsupported
major.minor version 51.0.
Reading several posts, the Unsupported major.minor version 51.0 seems like
it is an issue based on compilation of different java versions. The
version 51.0 looks to be java 7. To simply my testing, I uninstalled all
Java 7 installs from my machine, ensured that my eclipse projects point to
the same Java 6 JRE, and that my JAVA_HOME is set to Java 6u45. I also
restart eclipse to make sure my changes were in place.
I'm using Ant to create the jar file. The code is very simple and I even
specify the javac target to be 1.6.
<project name="XercesForAndroid" default="dist" basedir=".">
<description>
Builds jar for Xerces-For-Android
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac target="1.6" srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the .jar file -->
<jar jarfile="${dist}/lib/Xerces-For-Android.jar" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
After I run the ant script, I inspect the jar with 7-zip and find the
manifest shows 6u45 was used to make it.
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.)
Any ideas on what I could be missing? I don't see how Java 7 could be
referenced any more, but its seems like it is based on the 51.0
reference...
A couple other side notes:
I manually deleted the .jar file and did a clean on the Xerces-For-Android
project to ensure no old binaries were laying around.
I also did a clean on my sandbox project for testing the use of the jar
file. Same issue.
No comments:
Post a Comment