Phase 1 of 20 · Topic 1.2

Compilation & Execution Pipeline (.java -> .class -> JVM)

1Concept

1. Compilation: javac compiles source code (.java) into bytecode (.class). 2. ClassLoading: JVM ClassLoader loads .class files into memory. 3. Bytecode Verification: Verifies code does not violate memory access rules. 4. Execution: The JVM Execution Engine starts interpreting bytecode. Frequently called 'hotspots' are compiled into native machine code by the HotSpot JIT compiler.

2Architecture Diagram

[Source: App.java] ---> (javac App.java) ---> [Bytecode: App.class]
                                                    |
     +----------------------------------------------+
     v
[JVM ClassLoader Subsystem (Loading -> Linking -> Initialization)]
     |
     v
[Bytecode Verifier (Ensures safety, No illegal memory access)]
     |
     v
[Execution Engine: Interpreter (Immediate) + JIT Compiler (Native Assembly)] ---> CPU

3Code Example

Core Java
public class App {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int sum = a + b;
        System.out.println("Computed Sum: " + sum);
    }
}

4Expected Output

Computed Sum: 30

5Key Takeaways

  • Use 'javap -c ClassName' to inspect compiled JVM bytecode instructions.
  • Setting JAVA_HOME points to the JDK directory; PATH exposes the 'java' and 'javac' binaries.
  • Public class names must match the .java file name.