A compiled Java .class file begins with the 4-byte magic 0xCAFEBABE, followed by a 2-byte minor and 2-byte major version. The major version identifies the JDK that can load it (e.g. 52 = Java 8, 61 = Java 17).
Bytes 4-5 = minor_version, bytes 6-7 = major_version (big-endian). Major 0x34=52 is Java 8, 0x3D=61 is Java 17.
CAUTION: identical to the Mach-O universal (fat) binary magic FAT_MAGIC. The bytes that follow disambiguate: a .class file's next field is the version, a Mach-O fat header's next field is a big-endian architecture count.
JAR files are ZIP containers (PK\x03\x04), not raw .class files.