Java – Which JDK Version was Used to Compile


The above error means you have deployed code that was compiled from a more recent JDK than the JVM you are deploying to.

Which version of java built my jar or *.class file?

Maybe you have supporting jar files that contain code from Java 1.8 but you are deploying to java 1.5 – that is when you’ll see java.lang.UnsupportedClassVersionError.

Most of the time you will be aware of the JDK and JVM versions you are working with but occasionally you may have supporting code that will need to be recompiled at an earlier version. If you have lots of code, the question will be which code needs to be recompiled.

You can determine this by unzipping one class from each jar file and testing the version like so:

// on Windows run this  
javap -v SomeJavaProgram.class

// on Mac, Linux, Unix, run this
javap -v SomeJavaProgram.class | grep major

If running from Windows, you will get a fairly large amount of output. You will find the text, “major version” within the first 10 lines.
If running from Mac, Linux, Unix, you will see something like this:
major version: 48

Regardless of OS, you can map the Major Version back to the JDK with this list:

45.3 = Java 1.1
46 = Java 1.2
47 = Java 1.3
48 = Java 1.4
49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9

About the Author Scott Salisbury

Scott is the creator of Motivated Code Pro and the Managing Partner of Pinch Hitter Solutions, Inc. Motivated Code Pro is devoted to helping developers build better software careers. Pinch Hitter Solutions ( is a consultancy focused on mobile app development and enterprise web work. Scott works primarily in Java and JavaScript and focuses on Spring and Ext JS.

Leave a Comment: