How To Check The Java Compiler Version From a .class File

This article provides an easy way to check the java version used to compile a Java .class file by using javap tool, which is available in JDK (Java Development Kit).

Simply run the following command:

Windows:

javap -verbose MyClass | findstr "major"

Linux:

javap -verbose MyClass | grep "major"

Don’t forget to replace MyClass above with your exact Java class.

You will see the result like below after running the above command in your command prompt (or terminal):

major version: 49

Then, this table will tell you which Java compiler version of the class:

Target Major.minor
1.1 45.3
1.2 46.0
1.3 47.0
1.4 48.0
5 (1.5) 49.0
6 (1.6) 50.0
7 (1.7) 51.0
8 (1.8) 52.0
9 (1.9) 53.0

0 0 vote
Article Rating
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Elisabeth
Elisabeth
2 years ago

Wow, it is awesome. Well done guys!

1
0
Would love your thoughts, please comment.x
()
x