If you read a .class file using a hex editor you will see that the first 4 hex codes are CA FE BA BE followed by something like 00 00 00 3D
Example:public class MyClass {
//Some java code...
}
javac MyClass.java
xxd Sample.class
00000000: cafe babe 0000 003d 000d 0a00 0200 0307 .......=........
00000010: 0004 0c00 0500 0601 0010 6a61 7661 2f6c ..........java/l
00000020: 616e 672f 4f62 6a65 6374 0100 063c 696e ang/Object...<in
00000030: 6974 3e01 0003 2829 5607 0008 0100 0653 it>...()V......S
00000040: 616d 706c 6501 0004 436f 6465 0100 0f4c ample...Code...L
00000050: 696e 654e 756d 6265 7254 6162 6c65 0100 ineNumberTable..
00000060: 0a53 6f75 7263 6546 696c 6501 000b 5361 .SourceFile...Sa
00000070: 6d70 6c65 2e6a 6176 6100 2100 0700 0200 mple.java.!.....
00000080: 0000 0000 0100 0100 0500 0600 0100 0900 ................
00000090: 0000 1d00 0100 0100 0000 052a b700 01b1 ...........*....
000000a0: 0000 0001 000a 0000 0006 0001 0000 0001 ................
000000b0: 0001 000b 0000 0002 000c ..........
CAFE BABE - This is called the Magic Number - A java class file is identified by these first 4 byte headers
00 00 00 3D - The next first 2 bytes (00 00) signifies the Minor Version of Java, and the next two (00 3D) when converted to decimal you get 61 - which implies the Java Major version - which is Java 17, so this class was built using Java-17 version
Java Version = Decimal (Hex)
Java SE 17 = 61 (3D)
Java SE 16 = 60 (3C)
Java SE 15 = 59 (3B)
Java SE 14 = 58 (3A)
Java SE 13 = 57 (39)
Java SE 12 = 56 (38)
Java SE 11 = 55 (37)
Java SE 10 = 54 (36)
Java SE 9 = 53 (35)
Java SE 8 = 52 (34)
Java SE 7 = 51 (33)
Java SE 6.0 = 50 (32)
Java SE 5.0 = 49 (31)
JDK 1.4 = 48 (30)
JDK 1.3 = 47 (2F)
JDK 1.2 = 46 (2E)
JDK 1.1 = 45 (2D)

Java Cafe Babe Bytecode
More Posts related to Java,
- How to Get List of All Country Codes in Java Using Locale Class
- Unsupported major.minor version 52.0 in java
- Java - How to set custom thread name?
- Get the current timestamp in Java
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- java: unclosed string literal [Error]
- Convert Java Byte Array to String with code examples
- Error: Can not find the tag library descriptor for
- Java 8 - Convert List to Map Examples
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Fix java.net.ProtocolException: Invalid HTTP method
- Java: Convert Stream to List
- Java equals method - Tutorial
- List of Java JDBC Database Driver Jars, Classes and URLs Details
- Read YAML file Java Jackson Library
- How to display Java Date Time timezone GMT/UTC offset using SimpleDateFormat
- List of Java Keywords
- Enable JSON Pretty Print in Java Jackson
- How to Word-Warp Console logs in IntelliJ
- Convert Map to List in Java 8 using Stream API
- Create a Directory using Java Code
- Ways to Convert Integer or int to Long in Java
- [Program] How to read three different values using Scanner in Java
- Java JDBC Example with Oracle Database Driver Connection
More Posts:
- Format Python Code in Visual Studio Code (VS Code) - Python
- ActivityManager Warning: Activity not started, its current task has been brought to the front - Android
- No connection available Use Connect-SPOService before running this CmdLet - SharePoint
- SharePoint - Use Today's Date Time in list view filter and calculated column - SharePoint
- Syntax error, parameterized types are only available if source level is 1.5 or greater [Java] - Eclipse
- Big Sur unsupported Mac [macOS] - MacOS
- Permanently set $PATH variable in Mac Zsh shell - MacOS
- Fix zsh: permission denied: script.sh - zsh