100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Java

JVM, JRE and JDK Explained

Understand the precise differences and containment relationship between the JVM, JRE, and JDK — a foundational concept and one of the most frequently asked Java interview questions.

Introduction to JavaBeginner8 min readJul 7, 2026
Analogies

1. Introduction

JVM, JRE, and JDK are three acronyms that every Java developer encounters immediately, and they are frequently confused with one another. Understanding exactly what each one is, and how they relate to each other, is essential both for writing and running Java programs correctly and for answering one of the most common Java interview questions.

🏏

Cricket analogy: Just as fans often confuse the ground, the venue, and the tournament even though each nests inside the next, developers confuse JVM, JRE, and JDK, understanding the distinction is a classic interview question in Java too.

The short version: JDK contains JRE, and JRE contains JVM. In other words, JDK ⊃ JRE ⊃ JVM — each is a superset of the one before it, adding more capability.

🏏

Cricket analogy: Just as an international tour squad contains the playing XI which contains the specialist bowling attack, JDK contains JRE which contains JVM, each layer a superset adding more capability than the one nested inside it.

2. Syntax

There is no code syntax for these components themselves since they are platform tools and runtime environments, not language constructs. However, you interact with them through command-line tools: javac (compiler, part of the JDK) and java (launcher, part of the JRE/JDK).

🏏

Cricket analogy: You can't write code for the pitch or the stadium itself, they're the venue not the game, but you interact with them through fixed tools: the toss coin as a javac-like prep step, and the umpire's whistle to start play, java-like launch.

text
javac HelloWorld.java   // uses the JDK's compiler to produce HelloWorld.class
java HelloWorld         // uses the JRE/JVM to run the compiled bytecode

3. Explanation

JVM (Java Virtual Machine): This is the engine that actually executes Java bytecode. It loads .class files, verifies the bytecode for safety, interprets or JIT-compiles it into native machine instructions, and manages runtime concerns like memory (via garbage collection). The JVM is an abstract specification, and different vendors provide concrete implementations (for example, HotSpot JVM from Oracle/OpenJDK). The JVM by itself cannot run a Java program without supporting class libraries.

🏏

Cricket analogy: The JVM is like the on-field umpire: it loads the match rules as .class files, checks for foul play via bytecode verification, makes real-time calls through interpret and JIT, and manages the ground's resources like GC, but it can't stage a match without the league's rulebook of class libraries, and boards like the ICC and BCCI run their own HotSpot-style implementation of that role.

JRE (Java Runtime Environment): The JRE bundles the JVM together with the core Java class libraries (such as java.lang, java.util, java.io) and other supporting files needed to run compiled Java applications. If you only need to RUN Java programs (not develop them), the JRE alone is sufficient. Critically, the JRE does NOT include a compiler — you cannot compile .java files with just a JRE.

🏏

Cricket analogy: The JRE is like a match-day kit bag: it bundles the umpire, the JVM, with the essential rulebooks, java.lang, java.util, java.io, needed to actually play, enough to run a match, but it has no coaching manual, a compiler, to develop new players.

JDK (Java Development Kit): The JDK is the full development kit for building Java applications. It includes everything in the JRE (and therefore the JVM), plus development tools such as the javac compiler, the jar archiving tool, the javadoc documentation generator, and debugging tools like jdb. If you want to write and compile Java code, you need the JDK.

🏏

Cricket analogy: The JDK is like a full academy membership: it includes match access, the JRE and JVM, plus coaching tools like the bowling machine, javac, video analysis software, jar-style packaging, a scouting report generator, javadoc, and an injury-diagnosis kit, jdb, you need the full academy to develop new players, not just watch matches.

So the containment relationship is: JDK contains JRE, and JRE contains JVM (JDK ⊃ JRE ⊃ JVM). A developer machine needs the JDK; a machine that only needs to run pre-compiled Java applications can get by with just the JRE (in modern practice, many deployments use custom minimal runtimes built with tools like jlink, but the classic JDK/JRE/JVM relationship remains the standard mental model).

🏏

Cricket analogy: A player who only needs to play matches needs just the JRE, kit and ground access, while a coach designing new drills needs the full JDK academy membership; modern franchises sometimes build lean custom camps like jlink for one skill, but the classic academy-to-match containment remains the standard mental model.

Quick memory aid: JVM runs bytecode. JRE = JVM + libraries (for running programs). JDK = JRE + development tools like javac (for building and running programs). Containment: JDK ⊃ JRE ⊃ JVM.

Common exam trap: Students often say 'JRE compiles Java code' — this is WRONG. Only the JDK includes the javac compiler. The JRE can only run already-compiled bytecode; it has no compiler at all.

4. Example

java
public class JdkJreJvmDemo {
    public static void main(String[] args) {
        System.out.println("To compile this file, javac (part of the JDK) is required.");
        System.out.println("To run the compiled .class file, the JVM (inside the JRE) is required.");
        System.out.println("Containment relationship: JDK contains JRE, JRE contains JVM.");
    }
}

5. Output

text
To compile this file, javac (part of the JDK) is required.
To run the compiled .class file, the JVM (inside the JRE) is required.
Containment relationship: JDK contains JRE, JRE contains JVM.

6. Key Takeaways

  • JVM executes bytecode and provides platform independence; it needs supporting class libraries to run real programs.
  • JRE = JVM + core class libraries; it can run Java programs but cannot compile them.
  • JDK = JRE + development tools such as javac, jar, and javadoc; it is required to write and compile Java code.
  • The containment relationship is JDK ⊃ JRE ⊃ JVM.
  • End users running a Java application only need a JRE (or equivalent runtime); developers need the full JDK.

Practice what you learned

Was this page helpful?

Topics covered

#Java#JavaProgrammingStudyNotes#Programming#JVMJREAndJDKExplained#JVM#JRE#JDK#Explained#StudyNotes#SkillVeris