Here's the full error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/apache/commons/io/FilenameUtils, offset=6
at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:540)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
at java.net.URLClassLoader.access$300(URLClassLoader.java:79)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1038)
at java.security.AccessController.doPrivileged(AccessController.java:284)
at java.net.URLClassLoader.findClass(URLClassLoader.java:429)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
......
I know it's very common error, but i wouldn't post a question here without spending at least 72 hours trying to fix my issue :). I know why this error appears (I just fixed a bunch of these by compiling with the correct bytecode version), but this is the one last bugger i can't get rid of. So my Java version is as below (yeah i know, old, but organization restrictions ... :p).
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap6460sr9fp2-20110627_03(SR9 FP2))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc64-64 jvmap6460sr9-
20110624_85526 (JIT enabled, AOT enabled)
J9VM - 20110624_085526
JIT - r9_20101028_17488ifx17
GC - 20101027_AA)
JCL - 20110530_01
The surprising part is that I get this error even with FileNameUtils 2.2 which is compatible with JDK 1.5!
I'm using IntelliJ to compile. These are the places where I set my target bytecode version to 1.5:
I'm at a total loss comprehending why FileNameUtils 2.2 (and even 1.6) would throw a bad major version error when my bytecode version is one whole level lower than the 1.6 that runs the code.
I've tried Build, Rebuild and Re-import Maven Dependencies too! I hope someone can help me fix the issue.
Here's what worked for me. My artifact configuration in IntelliJ was still pulling newer dependency versions that i had used earlier. I realized i needed to downgrade the versions of some dependencies so i updated my pom.xml. Somehow the artifact did not have the refreshed dependency versions on compiling.
I removed the existing artifact from my IntelliJ config and executed a maven goal this time. This helped pull the correct versions of all dependencies.