I am using xjc ant task to generate java classes from xsd and wsdl and then i am generating a jar out of these generated classes. PFB the code i am using,
<!-- Below code generates java classes from wsdl -->
<exec executable="xjc">
<arg value="-wsdl" />
<arg value="${wsdl}/mysample.wsdl" />
<arg value="-d" />
<arg value="${myclasses}" />
<arg value="-d" />
<arg value="${myclasses}" />
<arg value="${xsdfile}/mysample.xsd" />
</exec>
<!-- Below code generates jar from java classes -->
<jar destfile="${jars}/mysample.jar" basedir="${myclasses}"/>
It works fine in my local with JDK7 but when i deploy it to my server which has jdk6 i am getting <pre>org.jboss.resteasy.spi.UnhandledException: java.lang.UnsupportedClassVersionError: com/my/webservices/mysampleweb
. Any suggestion how to make this work??
EDIT:
I am getting major version 51 is newer than 50, the highest major version supported by this compiler.
error for some classes which were generated from xsd. How to resolve this??
I checked my ANT_HOME,java version and jre everything is fine.. But still i am getting the above error when build using ant via command line.. Any suggestion
If you're building with Java version 7 and trying to run it on Java 6 - or really anything earlier than the version of Java you compiled with - you'll get this UnsupportedClassVersionError. Compiled Java bytecode is forwards-compatible with new releases of the JVM, but not backwards compatible. Put Java 7 on your runtime environment, or compile using JDK 6.
Specifically, from Oracle's documentation of the Java 7 release:
Binary Compatibility
Java SE 7 is binary-compatible with Java SE 6 except for the incompatibilities listed below. Except for the noted incompatibilities, class files built with the Java SE 6 compiler will run correctly in Java SE 7.
The class file version for Java SE 7 is 51, as per the JVM Specification, because of the invokedynamic byte code introduced by JSR 292. Version 51 class files produced by the Java SE 7 compiler cannot be used in Java SE 6.