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. I've since updated the source code to cope with more modern versions of Java class files.

/**
 * Mon Nov 19 00:32:13 GMT 2007
 * This simple application is released under GPL 3.0
 * See enclosed licence file
 */
package com.technojeeves.util;

import java.io.InputStream;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

import java.util.Stack;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipException;

/**
 @author Charles Johnson
 */
public class JVersion implements FilenameFilter {
    private Map<File, Short> versions;

    public JVersion() {
        versions = new TreeMap<>();
    }

    public Map<File, Short> getVersions() {
        return versions;
    }

    public Map<File, String> getVersionsFriendlyNamed() {
        Map<File, String> result = new HashMap<>();
        for (Map.Entry<File, Short> entry : versions.entrySet()) {
            int version = entry.getValue() - 44;
            String v = Integer.toString(version);
            String newValue = version <= 8 ? "1." + v : v;
            result.put(entry.getKey(), newValue);
        }
        return result;
    }

    public static void main(String[] args) {
        if (args.length < 1) {
            System.err.println("Usage: zip.JVersion <root dir>");
            System.exit(-1);
        }

        try {
            JVersion jver = new JVersion();
            jver.list(args[0]);
            Map<File, Short> versions = jver.getVersions();
            if (versions.size() > 0) {
                for (Map.Entry<File, String> e : jver.getVersionsFriendlyNamed().entrySet()) {
                    System.out.printf("%s=%s%n", e.getKey(), e.getValue());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void list(String rootDir) throws IOException {
        List<File> jars = new ArrayList<File>();
        getJars(new File(rootDir), jars);
        // listEntries(jars, searchString);
        getVersions(jars);
    }

    private void getVersions(List<File> files) throws IOException {
        JarFile jar = null;
        Stack<Short> versionStack = new Stack<>();
        File f = null;

        for (int i = 0; i < files.size(); i++) {
            versionStack.clear();
            f = (File) files.get(i);
            if (f.getName().endsWith(".class")) {
                // class file
                try (InputStream in = new FileInputStream(f)) {
                    processBinary(in, versionStack);
                }
            } else {

                jar = new JarFile(f);

                Enumeration entries = jar.entries();

                for (; entries.hasMoreElements();) {
                    JarEntry entry = (JarEntry) entries.nextElement();
                    String entryName = entry.getName();
                    if (entryName.endsWith(".class")) {
                        try (InputStream in = jar.getInputStream(entry)) {
                            processBinary(in, versionStack);
                        }
                    }
                }
            }
            // end if class
            // Make a Map entry
            versions.put(f, versionStack.pop());
            // end for entries
        }
        // end for jars
    }

    private void processBinary(InputStream in, Stack<Short> versionStack) throws IOException {
        // Make sure the highest version is on the stack
        Short majorVersion = getMajorVersion(in);
        if (versionStack.isEmpty()) {
            versionStack.push(majorVersion);
        } else {
            if (majorVersion.compareTo(versionStack.peek()) > 0) {
                versionStack.pop();
                versionStack.push(majorVersion);
            }
        }
    }

    private short getMajorVersion(InputStream in) throws IOException {
        short result = -1;
        DataInputStream din = new DataInputStream(in);
        din.skip(6L);
        result = din.readShort();
        return result;
    }

    public boolean accept(File file, String name) {
        // System.out.printf("Is directory: %b, Name: %s\n", file.isDirectory(),
        // file.getName());
        return file.isDirectory() || name.toLowerCase().endsWith(".jmod") || name.toLowerCase().endsWith(".jar");
    }

    private void getJars(File f, List<File> jars) {
        if (f.isDirectory()) {
            File[] files = f.listFiles(this);

            for (int i = 0; i < files.length; i++) {
                getJars(files[i], jars);
            }
        } else if (f.isFile() && (f.getName().toLowerCase().endsWith(".jmod"))
                || f.getName().toLowerCase().endsWith(".class") || f.getName().toLowerCase().endsWith(".jar")) {
            jars.add(f);
        }
    }
}