The execution of Java code is a two-step process. Initially, the compilation is done by a compiler independent of the operating system. This is passed on to the Java Virtual Machine(JVM) for execution. The compilation phase involves the generation of 'bytecode' which is a .class file that can be run anywhere on any system making it platform-independent. The bytecode is generated after parsing, syntax analysis, attribute checking and organizing the control flow of the program. This code is passed onto the JVM. JVM loads the class, verifies the generated bytecode and then uses a Just-In-Time compiler.