Is there any way to find the java version from a compiled java .class file ?
Asked
Active
Viewed 142 times
4
-
You can use the bcel library for that – fge Feb 25 '14 at 09:38
2 Answers
3
You're looking for this on the command line (for a class called MyClass):
javap -verbose MyClass
You want the major version from the results. Here are some example values:
Java 1.2 uses major version 46
Java 1.3 uses major version 47
Java 1.4 uses major version 48
Java 5 uses major version 49
Java 6 uses major version 50
Java 7 uses major version 51

Damian Leszczyński - Vash
- 30,365
- 9
- 60
- 95

kumar
- 148
- 6
- 25
0
You may try to get the version of your class using:
javap -verbose help
The javap comes with jdk and the verbose
tells the version.
> javap -verbose help
Compiled from "help.java"
public class help
SourceFile: "help.java"
minor version: 0
major version: 46

Rahul Tripathi
- 168,305
- 31
- 280
- 331