Skip to content
doubtly

2 answers

A Java program is first compiled into bytecode by javac and then the bytecode is executed by the JVM.

  1. Write (edit): the source code is typed in a file with extension .java, e.g. Hello.java (named after the public class).
  2. Compile: javac Hello.java. The compiler checks syntax and produces Hello.class, which contains bytecode, a platform-independent intermediate code.
  3. Load: java Hello starts the JVM; the class loader loads Hello.class (and other needed classes) into memory.
  4. Verify: the bytecode verifier checks that the code is valid and safe (no illegal memory access, correct types).
  5. Execute: the JVM's interpreter runs the bytecode, and the JIT compiler converts frequently used parts into native machine code for speed. The program's output appears.

Because the same .class file can run on any machine that has a JVM, Java is "write once, run anywhere".

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.