• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

CAFEBABE

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
couple of days before i took a technical test in java.
the first questions was "What is CAFEBABE in Java?" can anyone
explain to me what it is?
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
look for that on google and u'll find more
CAFEBABE is a magic word for a class file. as u might observe it is consisting of only hex letters. if the class file doesn't have this magic word then it is not a valid class file (well i'm myself little unsure about this on various systems Windows/Linux/Unix as magic word is used by mostly Unix based systems so i donno if Windows jvm cares about CAFEBABE or not)...
regards
maulin.
 
O. Subramaniam
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where this magical word will be stored, can v read this word?
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by O. Subramaniam:
where this magical word will be stored, can v read this word?


Hi,
Best option is to try out yourself. I found out from the net that "CAFEBABE" are
the starting bytes of each and every java class files.
So here is the program to find out the truth.

If we run this program using the command

we see that the first bytes are indeed "CAFEBABE".
HTH
ALan
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm... under Windows, using cygwin's "od -t x2 blah.class" to show me what's in the file, I get "feca beba".
Not nearly as cool sounding as CAFEBABE.
[ August 14, 2003: Message edited by: Roy Tock ]
 
Vadiraj Deshpande
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Roy Tock:
Hmmm... under Windows, using cygwin's "od -t x2 blah.class" to show me what's in the file, I get "feca beba".
Not nearly as cool sounding as CAFEBABE.
[ August 14, 2003: Message edited by: Roy Tock ]


May be because of platform encoding or with cygwin?
As you can see, if you reverse the hex words we get "CAFEBABE" again.

-A
[ August 18, 2003: Message edited by: Allan Deshpande ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic