MediumJava Interview Prep Series — #2 JDK vs JRE vs JVM | by engg_nirbhay | Medium
Sitemap

Java Interview Prep Series — #2 JDK vs JRE vs JVM

5 min readAug 18, 2026

--

If you’re preparing for Java interviews, JDK, JRE, and JVM are some of the most fundamental concepts you should understand clearly.

These three components work together to develop, compile, and run Java applications.

Let’s understand them step by step.

1. What is JDK?

JDK stands for Java Development Kit.

The JDK is the complete package required to develop Java applications.

If you want to write Java programs, compile them, debug them, and run them, you need the JDK.

What does JDK contain?

The JDK provides:

  • Java Compiler (javac)
  • JRE/runtime components
  • Debugging tools
  • Documentation tools
  • Other development utilities

The most important tool is the Java Compiler.

For example, when you write:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}

and save it as:

HelloWorld.java

You can compile it using:

javac HelloWorld.java

The compiler converts the .java source file into:

HelloWorld.class

The .class file contains Java bytecode.

So, in simple terms:

JDK is used to develop, compile, and run Java applications.

2. What is JRE?

JRE stands for Java Runtime Environment.

JRE provides everything required to run an already compiled Java application.

It contains:

  • JVM
  • Core Java libraries
  • Other runtime components

However, the JRE does not contain the Java compiler.

So, if you already have a compiled Java application and only want to run it, you need the runtime environment rather than the complete development kit.

In simple terms:

JRE is used to run Java applications.

The relationship can be represented as:

JRE
├── JVM
└── Java Runtime Libraries

3. What is JVM?

JVM stands for Java Virtual Machine.

The JVM is the engine that executes Java bytecode.

When Java source code is compiled, it is converted into bytecode stored inside a .class file.

The JVM takes this bytecode and executes it on the underlying operating system and hardware.

The JVM is responsible for several important tasks, including:

  • Loading classes
  • Verifying bytecode
  • Executing bytecode
  • Converting/compiling bytecode into native machine instructions
  • Managing memory
  • Garbage Collection
  • Providing other runtime services

In simple terms:

JVM is responsible for executing Java bytecode.

4. JDK vs JRE vs JVM

This is one of the most common Java interview questions.

ComponentPurposeContainsJDKDevelop Java applicationsDevelopment tools + RuntimeJRERun Java applicationsJVM + Runtime LibrariesJVMExecute bytecodeBytecode execution engine

The easiest way to remember the relationship is:

JDK
└── JRE
└── JVM

Or simply:

JDK → Develop
JRE → Run
JVM → Execute

5. How Does a Java Program Actually Run?

Let’s understand this using a simple HelloWorld program.

Step 1: Write Java Source Code

Create a file:

HelloWorld.java

with the following code:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}

This is Java source code.

Step 2: Compile the Source Code

We use the Java compiler provided by the JDK:

javac HelloWorld.java

The compiler converts:

HelloWorld.java

into:

HelloWorld.class

The .class file contains bytecode.

Important:

Bytecode is neither Java source code nor native machine code. It is an intermediate representation designed to be executed by the JVM.

Step 3: Run the Program

Now execute:

java HelloWorld

The bytecode is loaded by the JVM.

Get engg_nirbhay’s stories in your inbox

Join Medium for free to get updates from this writer.

The JVM executes the bytecode and produces the output:

Hello Java

6. Complete Java Execution Flow

The complete process can be visualized as:

Java Source Code
|
| javac
↓
Bytecode
(.class)
|
| JVM
↓
Machine Instructions
|
↓
Output

For example:

HelloWorld.java
↓
Java Compiler
(javac)
↓
HelloWorld.class
(Bytecode)
↓
JVM
↓
Machine Instructions
↓
Hello Java

This explains the roles of all three components:

JDK → Used to develop and compile the program.

JRE → Provides the runtime environment.

JVM → Actually executes the bytecode.

7. Why Does JVM Make Java Platform-Independent?

This is an important interview concept.

Suppose you compile your Java program on Windows.

The compiler generates Java bytecode:

.class

That bytecode doesn’t contain Windows-specific machine instructions.

The same bytecode can be executed on:

  • Windows
  • Linux
  • macOS

provided there is a compatible JVM for that platform.

For example:

Java Source
↓
javac
↓
Bytecode
↓
┌──────────┼──────────┐
↓ ↓ ↓
Windows Linux macOS
↓ ↓ ↓
JVM JVM JVM
↓ ↓ ↓
Execute Execute Execute

This is the foundation of Java’s famous principle:

Write Once, Run Anywhere (WORA)

Important Interview Point

Java bytecode is platform-independent, but the JVM itself is platform-dependent.

Different operating systems require different JVM implementations.

8. Which One Should You Install?

This is a common practical question.

If you only want to run Java applications

You need the runtime environment.

If you want to develop Java applications

You should install the JDK.

As a developer, the JDK is what you normally install because it provides the tools required for development along with the runtime components.

9. Common Interview Questions

Q1. What is JDK?

JDK is the Java Development Kit used to develop, compile, debug, and run Java applications.

Q2. What is JRE?

JRE is the Java Runtime Environment used to run Java applications.

It provides the JVM and runtime libraries.

Q3. What is JVM?

JVM is the Java Virtual Machine that executes Java bytecode.

Q4. Which component contains the Java compiler?

JDK.

The Java compiler is commonly invoked using:

javac

Q5. Does JRE contain the Java compiler?

No.

The compiler is part of the JDK.

Q6. What does a .class file contain?

A .class file contains Java bytecode generated by the Java compiler.

Q7. Which component actually executes bytecode?

JVM.

Q8. Why is Java platform-independent?

Java source code is compiled into platform-independent bytecode, which can be executed by a JVM implementation available for the target platform.

Q9. Is JVM platform-independent?

No.

JVM implementations are platform-specific.

For example, the JVM implementation for Windows is different from the JVM implementation for Linux.

Q10. What should a Java developer install?

JDK.

The JDK provides the tools required to develop and compile Java applications.

10. Quick Revision

Remember these three lines:

JDK → Develop + Compile + Run
JRE → Run
JVM → Execute Bytecode

And the relationship:

JDK
└── JRE
└── JVM

In One Sentence

JDK provides the tools to develop Java applications, JRE provides the environment to run them, and JVM is the engine that executes Java bytecode.

Final Takeaway

Understanding JDK, JRE, and JVM is essential before diving deeper into Java.

Once you understand the journey:

.java
↓
javac
↓
.class
↓
Bytecode
↓
JVM
↓
Machine Instructions
↓
Output

many other Java concepts — such as class loading, memory management, garbage collection, JIT compilation, and JVM internals — become much easier to understand.

This is one of those topics where memorizing definitions isn’t enough.

Try to understand what happens behind the scenes when you run a Java program.

That understanding will help you answer Java interview questions with much more confidence.

Java Interview Prep Series #2 — JDK vs JRE vs JVM

--

--

engg_nirbhay
engg_nirbhay

Written by engg_nirbhay

DSA | LLD | HLD | JAVA | MYSQL | OS | CN | DBMS | BACKEND