Difference Between JDK, JRE & JVM

Java programs rely on three fundamental components during their lifecycle: the JDK, JRE, and JVM. While they are closely related, each plays a different role — from writing code to executing it.

Let’s break them down individually and then compare them side by side.


1. JVM (Java Virtual Machine)

Purpose:
The JVM is the engine that actually runs Java applications. It reads and interprets Java bytecode and converts it to machine-specific instructions.

Responsibilities:

  • Loads .class files (bytecode)
  • Verifies code for safety
  • Executes code via interpreter or JIT compiler
  • Manages memory and garbage collection

Key Point: It is platform-dependent (i.e., different JVMs for Windows, Linux, etc.), but the bytecode is platform-independent.


2. JRE (Java Runtime Environment)

Purpose:
The JRE provides the runtime environment required to run Java applications. It includes the JVM along with essential libraries and components.

Components:

  • Java Virtual Machine (JVM)
  • Core Java libraries (e.g., java.lang, java.util)
  • Configuration files and supporting files

Use Case:
For end-users or servers that only need to run Java programs and not develop them.


3. JDK (Java Development Kit)

Purpose:
The JDK is the complete software development kit required to write, compile, debug, and run Java programs. It includes both JRE and JVM, along with development tools.

Components:

  • JRE (which includes JVM)
  • Compiler (javac)
  • Debugger (jdb)
  • Documentation generator (javadoc)
  • Java tools like jar, jconsole, jshell

Use Case:
Used by developers to build Java applications.


Comparison Table: JDK vs JRE vs JVM

FeatureJDKJREJVM
Full FormJava Development KitJava Runtime EnvironmentJava Virtual Machine
Primary PurposeDevelop and run Java programsRun Java programsRun compiled bytecode
Contains JVM✅ Yes✅ Yes❌ No
Contains JRE✅ Yes❌ No❌ No
Development Tools Included✅ Yes❌ No❌ No
Bytecode Execution✅ Yes✅ Yes✅ Yes
Includes Compiler (javac)✅ Yes❌ No❌ No
Platform DependencyPlatform dependentPlatform dependentPlatform dependent
Use CaseDevelopersEnd-users / ServersInternal engine of JRE & JDK

Summary

  • JVM is the core engine that executes Java bytecode.
  • JRE provides the runtime environment including the JVM and standard libraries.
  • JDK is a complete development kit including both the JRE and JVM along with essential development tools.