How Java Works – Step by Step way

  1. Write Code (Source Code)
    • You write a Java program and save it as a .java file.
    • Example: HelloWorld.java
  2. Compilation (Java Compiler – javac)
    • The Java compiler converts your human-readable code (.java) into bytecode (.class file).
    • Bytecode is platform-independent, meaning it can run on any machine that has a JVM.
  3. Execution (Java Virtual Machine – JVM)
    • The JVM reads the bytecode and executes it line by line.
    • Inside JVM:
      • Class Loader loads the .class files.
      • Bytecode Verifier checks for security and validity.
      • Interpreter / JIT Compiler (Just-In-Time) converts bytecode into machine code for your specific OS/CPU to run faster.
  4. Runtime Environment (JRE)
    • The Java Runtime Environment (JRE) provides the libraries, JVM, and other components required to run the program.
  5. Development Kit (JDK)
    • The Java Development Kit (JDK) includes both JRE + tools (like javac, debugger, etc.) to develop and run programs.

Leave a Reply

Your email address will not be published. Required fields are marked *