Write once, run anywhere works because javac compiles .java source files into standardized platform-neutral .class bytecode rather than raw ARM or x86 instructions. Every .class begins with magic bytes 0xCAFEBABE followed by class version, a Constant Pool symbol table, and method bytecodes.
More lessons in Complete Core Java