Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🟢 Foundation  ·  Lesson 02

JDK vs JRE vs JVM in Java

In this lesson: Understand JDK, JRE and JVM — what each does, how they fit together and which one you need — with diagram and table.

Three key pieces

To understand Java, you need three names: JVM, JRE and JDK. They sound similar but do different jobs. In short: the JVM runs your code, the JRE lets you run Java, and the JDK lets you write Java. They are nested inside each other.

💡 JDK contains the JRE, and the JRE contains the JVM. Install the JDK to get all three.

JVM — the engine

The Java Virtual Machine is the engine that runs Java bytecode (the compiled form of your code). It reads bytecode and executes it on your device. Because each operating system has its own JVM, the same bytecode runs on Windows, Mac and Linux — the heart of "write once, run anywhere".

JRE — to run Java

The Java Runtime Environment is everything needed to run a Java program. It includes the JVM plus the standard libraries your program uses. If you only want to run finished Java apps and not write them, the JRE is enough.

JDK — to write Java

The Java Development Kit is everything needed to write and compile Java. It includes the JRE plus developer tools — most importantly the compiler javac, which turns your .java code into bytecode. Learners and developers install the JDK.

javac Hello.java   // JDK's compiler makes bytecode
java Hello         // JRE's JVM runs it

How they fit together

Think of them as boxes inside boxes:

JDK  (write + compile + run)
 └── JRE  (run)
      └── JVM  (execute bytecode)

The JDK is the biggest — it contains the JRE, which contains the JVM. So installing the JDK automatically gives you the JRE and the JVM too.

Quick comparison

PartPurposeContainsWho needs it
JVMRuns bytecodeThe engineEveryone (inside JRE)
JRERun Java appsJVM + librariesUsers running Java
JDKWrite + compileJRE + toolsDevelopers, learners

Common mistakes

  • Installing only the JRE to code. You need the JDK to compile with javac.
  • Thinking they are separate downloads to combine. The JDK already includes JRE and JVM.
  • Confusing the JVM with the whole of Java. The JVM is just the execution engine.
  • Expecting bytecode to run without a JVM. Every device needs a JVM to run Java.

Summary

  • JVM runs Java bytecode and makes Java platform-independent.
  • JRE = JVM + libraries, enough to run Java programs.
  • JDK = JRE + tools (like the compiler), needed to write Java.
  • They nest: JDK contains JRE contains JVM.
  • Install the JDK to get all three for development.

Next, set up the JDK in the Java setup guide, or write your first program in Hello World.

Frequently Asked Questions

What is the difference between JDK, JRE and JVM?
The JVM runs Java bytecode. The JRE contains the JVM plus libraries needed to run Java programs. The JDK contains the JRE plus tools to write and compile Java, like the compiler. So JDK is for developers, JRE is for running.
What is the JVM?
The JVM (Java Virtual Machine) is the engine that executes Java bytecode. Because each platform has its own JVM, the same bytecode runs everywhere — this is what makes Java platform-independent.
What is the JRE?
The JRE (Java Runtime Environment) is what you need to run a Java program. It includes the JVM and the standard libraries, but not the developer tools like the compiler.
Do I need the JDK or the JRE?
If you write and compile Java code, you need the JDK (it includes everything). If you only run finished Java programs, the JRE is enough. Learners should install the JDK.
How do JDK, JRE and JVM relate to each other?
They are nested: the JDK contains the JRE, and the JRE contains the JVM. So installing the JDK gives you all three, which is why developers install the JDK.
← Back to Java Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicJava Setup and Installation Your progress: 2 / 61 (3%) · Lesson 3 / 61 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free