I believe I've seen all of the other posts on this issue. I think this is a different question because I am looking for a way to determine which class is causing the problem.
I build my jar using Maven.
If I ask it to build for Java 5 and I run it under Java 6 it works fine.
If I ask it to build for Java 6 and I run it under Java 6 it works fine.
If I ask it to build for Java 5 and I run it under Java 5 it fails:
java.lang.RuntimeException: public static void ....main(java.lang.String[]) failed for arguments (String[]{...})
Caused by: java.lang.reflect.InvocationTargetException:
...
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
...
I have inspected the jar using Java Version Check and it reports all classes in the jar as built for Java 5.
I can only conclude that it is hacking its own classpath and linking up with some other library/jar on my machine that is not Java 5. This is quite possible but I do not have access to the source of that process and as far as I am aware I cannot single-step into the class loader to find out which class it is loading.
Are there any techniques I can use that will help me work out which class is causing the exception?