Version of Java class in a jar

for (Enumeration e = jar.entries(); e.hasMoreElements();) {
var je = e.nextElement();
if (!je.getName().endsWith(“.class”)) {
continue;
}
System.out.println(je.getName());
try (DataInputStream in = new DataInputStream(jar.getInputStream(je))) {
int magic = in.readInt();
if (magic != 0xCAFEBABE) {
continue;
}
int minor = in.readUnsignedShort();
int major = in.readUnsignedShort();
System.out.println(String.format(“Major %d minor %d”, major, minor));
break;
}
}