Use the javap tool that comes with the JDK. The -verbose
option will print the version number of the class file.
> javap -verbose MyClass
Compiled from "MyClass.java"
public class MyClass
SourceFile: "MyClass.java"
minor version: 0
major version: 46
...
To only show the version:
WINDOWS> javap -verbose MyClass | find "version"
LINUX > javap -verbose MyClass | grep version
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…