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:
To get at a class inside a JAR, extract the JAR with any standard zip tool and run javap on an individual class file:
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 Version | JDK Version |
| 45 | 1.1 |
| 46 | 1.2 |
| 47 | 1.3 |
| 48 | 1.4 |
| 49 | Java SE 5 |
| 50 | Java SE 6 |
| 51 | Java SE 7 |
| 52 | Java SE 8 |
| 53 | Java SE 9 |
| 54 | Java SE 10 |
| 55 | Java SE 11 |
| 56 | Java SE 12 |
| 57 | Java SE 13 |
| 58 | Java SE 14 |
| 59 | Java SE 15 |
| 60 | Java 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.
Related reading
- What will happen if takeLeadership() never return when using Curator's Leader Election
- What would be the fastest method to test for primality in Java?
- What's a monitor in Java?
- What's invokedynamic and how do I use it?
- What's the advantage of a Java enum versus a class with public static final fields?
- What's the best mock framework for Java?
- What's the best open-source Java Bayesian spam filter library?
- What's the best way of accessing field in the enclosing class from the nested class?
System design interview problems on this topic
- Design an API Rate Limiter: solution and walkthrough
- Design a Distributed Messaging System: solution and walkthrough
- Design an Online Payment Service: solution and walkthrough
- Design a Key Value Store: solution and walkthrough

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData 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.