java 7 - ant xjc task to work with jdk 6 -


i using xjc ant task generate java classes xsd , wsdl , generating jar out of these generated classes. pfb code using,

    <!-- below code generates java classes 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 java classes  -->         <jar destfile="${jars}/mysample.jar" basedir="${myclasses}"/> 

it works fine in local jdk7 when deploy server has jdk6 getting <pre>org.jboss.resteasy.spi.unhandledexception: java.lang.unsupportedclassversionerror: com/my/webservices/mysampleweb. suggestion how make work??

edit: getting major version 51 newer 50, highest major version supported compiler. error classes generated xsd. how resolve this??

i checked ant_home,java version , jre fine.. still getting above error when build using ant via command line.. suggestion

if you're building java version 7 , trying run on java 6 - or earlier version of java compiled - you'll unsupportedclassversionerror. compiled java bytecode forwards-compatible new releases of jvm, not backwards compatible. put java 7 on runtime environment, or compile using jdk 6.

specifically, oracle's documentation of java 7 release:

binary compatibility

java se 7 binary-compatible java se 6 except incompatibilities listed below. except noted incompatibilities, class files built java se 6 compiler run correctly in java se 7.

the class file version java se 7 51, per jvm specification, because of invokedynamic byte code introduced jsr 292. version 51 class files produced java se 7 compiler cannot used in java se 6.


Comments