Start Coding Now

Compile Time vs Runtime in Java

Difference between compile-time and runtime. Understand what happens during compilation and execution of a Java program.

Compile Time

  • Who: Java Compiler (javac)
  • Input: Source code (.java)
  • Output: Bytecode (.class)
  • Errors: Syntax errors (missing semicolon, wrong type)

Runtime

  • Who: Java Virtual Machine (JVM)
  • Input: Bytecode (.class)
  • Output: Program execution
  • Errors: Runtime exceptions (DivByZero, NullPointer)

Process

  • Write: Main.java
  • Compile: javac Main.java -> Main.class
  • Run: java Main
  • Frequently Asked Questions