File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes urgent doubt regarding class files! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "urgent doubt regarding class files!" Watch "urgent doubt regarding class files!" New topic
Author

urgent doubt regarding class files!

manojchandranssi
Greenhorn

Joined: Aug 08, 2002
Posts: 1
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

Joined: May 10, 2001
Posts: 3244
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!!


Dave
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
And of course, the magic number is . . .CAFEBABE (it really IS).


"JavaRanch, where the deer and the Certified play" - David O'Meara
Neil Laurance
Ranch Hand

Joined: Jul 18, 2002
Posts: 183
I never knew that Cindy
To see this string in UNIX, try:
od -tx1 <class file> | head -1
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

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
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent doubt regarding class files!
 
Similar Threads
can non-static inner class access any member
andrew has wii
Doubt about diagram class
WA #1.....word association
Doubt about diagram class (realization)