Search code examples
javaunsupported-class-version

Java UnsupportedClassVersionError Issue


I understand the UnsupportedClassVersionError to be caused when I compile my java files in a newer version than the JVM the class file will be run on.

I'm working on a program that will run on an IBM i Series box, which is running Java 1.6. I've cross-compiled my files to use 1.5 for the source and target values. The actual command used is:

javac -source 1.5 -target 1.5 -bootclasspath C:/dev/languages/java/jdk1.5.0_22/jre/lib/rt.jar -extdirs "" -classpath "c:/dev/QIBM/ProdData/OS400/jt400/lib/*;/psmssys/java/src/com/gy/as400/common;." $(find ./com/gy/as400/bladder/install/* | grep .java)

Understand I am compiling the files on a Win 7 box running Java 1.8.0_131

Once the classes are compiled if I then run

javap -verbose

on any of the resulting classes, the Major Version shows 49which according to this wiki article should be compatible with JVM 1.5 and up.

I've tried to cross-compile to 1.4 but that would require me to rewite a significant portion of my code to not use FOR...EACH and generic lists.

What am I missing here.


Solution

  • Thank you @rdean400.

    I got to thinking and went back through my transfer logs and found some errors had occurred moving the class from my dev box to the test box. I cleared out all the existing class files and transferred them again. This resolved the UnsupportedClassVersionError.