0
0
Javaprogramming~10 mins

JDK, JRE, and JVM difference in Java - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - JDK, JRE, and JVM difference
Write Java Code
Use JDK to Compile
Bytecode (.class files)
Use JRE to Run
JVM Executes Bytecode
Program Output
Java code is written and compiled by JDK into bytecode, which is run by JRE using JVM to produce output.
Execution Sample
Java
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}
This Java program prints 'Hello World' to the screen.
Execution Table
StepComponentActionInputOutput
1DeveloperWrites Java source codeHello.javaJava code text
2JDK (javac)Compiles Java codeHello.javaHello.class (bytecode)
3JREPrepares runtime environmentHello.classReady to run bytecode
4JVMLoads and executes bytecodeHello.classPrints 'Hello World'
5ProgramEnds executionN/AProgram stops
💡 Program ends after printing output.
Variable Tracker
ComponentState BeforeState After
Java Source CodeNot writtenHello.java with code
BytecodeNot compiledHello.class file created
Runtime EnvironmentNot readyJRE ready to run bytecode
ExecutionNot startedProgram output displayed
Key Moments - 3 Insights
Why do we need both JDK and JRE?
JDK includes tools to write and compile code (see Step 2), while JRE only runs compiled code (Step 3). You need JDK to create programs and JRE to run them.
Is JVM part of JDK or JRE?
JVM is inside JRE (Step 4). JRE provides JVM to run bytecode, and JDK includes JRE plus tools to compile.
What does JVM actually do?
JVM reads the bytecode (.class files) and runs it on your computer (Step 4), turning code into actions like printing text.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, which component compiles the Java code?
AJVM
BJRE
CJDK
DDeveloper
💡 Hint
Check Step 2 in the execution table where compilation happens.
At which step does the JVM execute the bytecode?
AStep 2
BStep 4
CStep 3
DStep 5
💡 Hint
Look at Step 4 in the execution table where execution happens.
If you only have JRE installed, what can you NOT do?
ACompile Java source code
BExecute bytecode
CRun Java programs
DPrint output
💡 Hint
Refer to key moment about difference between JDK and JRE.
Concept Snapshot
JDK = Java Development Kit: tools to write and compile Java code.
JRE = Java Runtime Environment: runs compiled Java bytecode.
JVM = Java Virtual Machine: part of JRE that executes bytecode.
Write code -> Compile with JDK -> Run with JRE/JVM -> Output.
JDK includes JRE; JRE includes JVM.
Full Transcript
Java programs start as source code written by developers. The JDK compiles this code into bytecode files. The JRE provides the environment to run these bytecode files. Inside the JRE, the JVM executes the bytecode, turning it into actions like printing text. The JDK is needed to create and compile programs, while the JRE is enough to run them. JVM is the engine inside JRE that runs the code.