Java
Javac
Jar Files
Software Development
Programming Tools

How to check which Java version built a JAR

Codemia Knowledge Hub ·

Extract a class file from the JAR and run javap -verbose on it. The output includes the class file's major and minor version, and the major version maps to a Java release: 52 is Java SE 8, 55 is Java SE 11, 58 is Java SE 14 (full table below).

The JVM uses these version numbers to check compatibility, so they matter when you mix library dependencies or chase runtime errors between components built for different Java versions. Note that the number records the class file target: it matches the compiling JDK by default, but a newer javac run with an older --release or -target setting produces the older version number.

Where the version is stored

Every class file starts with the magic number CA FE BA BE (hexadecimal), followed by the minor and major version numbers. The major version identifies the Java release.

Reading the version with javap

javap, the class file disassembler that ships with the JDK, prints the major and minor version along with a lot of other information about the class:

bash
   javap -verbose ClassName.class

To get at a class inside a JAR, extract the JAR with any standard zip tool and run javap on an individual class file:

bash
   unzip myarchive.jar
   javap -verbose com/example/MyClass.class

When you have many JAR files to check, script the extraction and version detection in bash, Python or another scripting language.

Class file major version to Java release

Major VersionJDK Version
451.1
461.2
471.3
481.4
49Java SE 5
50Java SE 6
51Java SE 7
52Java SE 8
53Java SE 9
54Java SE 10
55Java SE 11
56Java SE 12
57Java SE 13
58Java SE 14
59Java SE 15
60Java SE 16

Deeper build metadata

For more detailed analysis, libraries such as BuildInfo dig further into JAR metadata and can sometimes reveal which build system (Maven, Ant and so on) produced the JAR, not just the Java version.


Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms