Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent doubt regarding class files!

 
manojchandranssi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For every program in java the .class file of it is starting with some ..e p3/4.. something like that ,what's it?Please give an immediate reply
thanx in advance,
Manoj Chandran
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And of course, the magic number is . . .CAFEBABE (it really IS).
 
Neil Laurance
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never knew that Cindy
To see this string in UNIX, try:
od -tx1 <class file> | head -1
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic