Sometimes you might need to establish beyond doubt what version of Java a class has been compiled to. You need to examine the header to find that out. The below shows how to do that. The source code is HERE

import java.io.*;


public class JavaVersion {
    private final static int HEADER_LENGTH = 8;

    public static void main(String[] args) {
        if (args.length < 1) {
            System.err.println("Usage: java JavaVersion <class file>");
            System.exit(1);
        }

        DataInputStream in = null;

        try {
            File f = new File(args[0]);
            in = new DataInputStream(new FileInputStream(f));

            byte[] header = new byte[HEADER_LENGTH];
            in.readFully(header);

            int javaVersion = header[HEADER_LENGTH - 1] & 0xFF;

            String versionString = null;

            switch (javaVersion) {
            case 0x34:
                versionString = "1.8";

                break;

            case 0x33:
                versionString = "1.7";

                break;

            case 0x32:
                versionString = "1.6";

                break;

            case 0x31:
                versionString = "1.5";

                break;

            case 0x30:
                versionString = "1.4";

                break;

            case 0x2F:
                versionString = "1.3";

                break;

            case 0x2E:
                versionString = "1.2";

                break;

            default:
                versionString = "UNKNOWN_VERSION";
            }

            System.out.println("Java class file version is " + versionString);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception e) { /* ignore */
            }
        }
    }
}