What is CA FE BA BE 00 00 00 3D in Java Class Bytecode


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
Java Cafe Babe Bytecode
Advertisements
Try Out Code2care Dev Tools:

Advertisements



Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Advertisements


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR - https://donate.unhcr.org/in/en-in/ukraine-emergency