Java Zero to All All questionsPractise free
Interview questions › Java Foundations — Zero to Basics › How Java Runs — JDK, JRE, JVM & Your First Program

Walk through what happens from a .java file to a running program.

Level II · JuniorHow Java Runs — JDK, JRE, JVM & Your First Program
Short answer

You write source in a .java file. The compiler javac checks it and produces one .class file per class, containing bytecode.

Explanation

You launch it with `java YourClass`; the JVM starts, its class loader loads the needed .class files, the bytecode verifier checks them for safety, and then the JVM executes your program starting at the main method -- interpreting the bytecode and, for hot code, JIT-compiling it to native machine code for speed.

Common mistakes
  • Skipping the class loading and verification step between compile and execute.
  • Mixing up javac (compiles) and java (launches the JVM).

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for How Java Runs — JDK, JRE, JVM & Your First Program.

Practise free

More on How Java Runs — JDK, JRE, JVM & Your First Program