manojchandranssi Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!!
To understand the class file format, consult the JVM spec. The first four bytes are always the same, a "magic number" which helps confirm that the file really is a Java class file and not something else (since it's unlikely any other file type would happen to begin with those 4 bytes). Note that you're evidently looking at the class file with a text editor. Most parts of a class file are binary data, not inteded to be interpreted as text. If you look at these with a text editor, you'll just see a lot of meaningless symbols. You want a binary viewer of some sort, combined with the JVM Spec to understand the parts. For binary viewing I often just change the file suffix to .bin and then open the file with TextPad. I'm sure there are other alternatives though.
Originally posted by Cindy Glass: And of course, the magic number is . . .CAFEBABE (it really IS).
That seems to be a popular scheme for magic numbers at SUN. The magic number for the database (db.db) file format in the Developer's assignment is C0C0BABE. Is that sexist or am I just being overly sensitive? Michael Morris
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Joined: Jan 30, 2000
Is that sexist or am I just being overly sensitive? The latter. By the way, Manoj - why was this "urgent", needing an "immediate" reply? We usually ignore such terms here anyway, but they seem particularly odd in this case. It's just a class file - your JVM already knows how to interpret it. If you're planning on doing anything else with it, you'll need to understand a lot more about the format than just the first four bytes...