Search code examples
javahexmagic-numbershex-editors

What hex code do .java files start with?


I'm trying to get the "magic number" (the bytes that say what format the file is)... I did try to open the file myself in a hex editor. But I only get "70 75" at the start. And that's wrong. I'm doing homework and can't find the right hex code. I do not have much experience with hex editors.


Solution

  • .java files are the source files. They're plain text files and don't have any particular magic number. 70 75 are the bytes of the characters pu - you were probably looking at a public class ... definition.

    Compiled Java .class files start with the bytes CA FE BA BE ("Café babe"). See Java Virtual Machine Specification §4.1 – The ClassFile Structure for a description of the format.