Possible major/minor value :
major minor Java platform version 45 3 1.045 3 1.146 0 1.247 0 1.348 0 1.449 0 1.550 0 1.6
import java.io.*;public class ClassVersionChecker { public static void main(String[] args) throws IOException { for (int i = 0; i < args.length; i++) checkClassVersion(args[i]); } private static void checkClassVersion(String filename) throws IOException { DataInputStream in = new DataInputStream (new FileInputStream(filename)); int magic = in.readInt(); if(magic != 0xcafebabe) { System.out.println(filename + " is not a valid class!");; } int minor = in.readUnsignedShort(); int major = in.readUnsignedShort(); System.out.println(filename + ": " + major + " . " + minor); in.close(); }}
> java ClassVersionChecker ClassVersionChecker.classClassVersionChecker.class: 49 . 0
from
magic
The magic item supplies the magic number identifying the class file format; it has the value 0xCAFEBABE.minor_version, major_version
The values of the minor_version and major_version items are the minor and major version numbers of this class file.Together, a major and a minor version number determine the version of the class file format. If a class file has major version number M and minor version number m, we denote the version of its class file format as M.m. Thus, class file format versions may be ordered lexicographically, for example, 1.5 < 2.0 < 2.1.A Java virtual machine implementation can support a class file format of version v if and only if v lies in some contiguous range Mi.0 v Mj.m. Only Sun can specify what range of versions a Java virtual machine implementation conforming to a certain release level of the Java platform may support.