Check the class versionFrom WikiJava
This tutorial will show how to get the version number of a compiled
the articleThe first 4 bytes are a magic number, 0xCAFEBABe, to identify a valid class file then the next 2 bytes identify the class format version (major and minor). Possible major/minor value : ClassVersionChecker.javaimport 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(); } } the output> java ClassVersionChecker ClassVersionChecker.class ClassVersionChecker.class: 49 . 0 See AlsoThe Java Virtual Machine Specification, Real's Java How To |
