4

Is there any way to find the java version from a compiled java .class file ?

keyser
  • 18,829
  • 16
  • 59
  • 101

2 Answers2

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
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