Skip to content

Differences Between JDK, JRE, and JVM?

Gopi Gorantala
Gopi Gorantala
2 min read

Table of Contents

Short answer

JDK, JRE, and JVM are essential components of the Java platform, each serving a distinct purpose. Here are the key differences between them:

  1. JDK (Java Development Kit): The JDK is used by developers to write, compile, and debug Java code.
  2. JRE (Java Runtime Environment): End-users use the JRE to run Java applications.
  3. JVM (Java Virtual Machine): The JVM is the runtime engine that executes Java bytecode, and it is included in both the JDK and the JRE.

More detailed answer

SDK Sketches and illustrations

Before we learn more about each one in detail, here is a diagram that shows the relationship between the JDK, JRE, and JVM.

JDK (Java Development Kit)
+--- JRE (Java Runtime Environment)
     +--- JVM (Java Virtual Machine)
     |    |
     |    +--- Just In Time Compiler (JIT)
     |    |
     |    +--- Heap, Stack, registry, and Other memory areas
     |    |
     |    +--- ...
     +--- Java Class Libraries
     |    |
     |    +--- java.lang Package
     |    |
     |    +--- Package
     |    |
     |    +--- java.util Package
     |    |
     |    +--- ...
     +--- Java Standard Extensions
          +--- JavaFX
          +--- Java Accessibility
          +--- Java Cryptography Extension (JCE)
          +--- ...

JDK - Java development kit

The JDK software development kit provided by Oracle Corporation contains tools, libraries, and documentation required for Java development. It includes the following components:

  • Java Compiler: The JDK includes the Java compiler, which translates Java source code (.java files) into bytecode (.class files) that the JVM can execute.
  • Java Runtime Environment (JRE): The JDK includes a JRE, which allows developers to run Java applications during development. It includes the JVM and the core libraries required for running Java programs.
  • Development Tools: The JDK provides various development tools like the debugger, profiler, JavaDoc generator, and more, which assist in writing, testing, and debugging Java code.

In summary, the JDK is used by developers to write, compile, and debug Java applications.

JRE (Java Runtime Environment)

The JRE is a subset of the JDK required to run Java applications. It includes the JVM and the necessary runtime libraries for executing Java programs. The JRE consists of the following components:

  • JVM (Java Virtual Machine): The JVM is the runtime engine that interprets and executes Java bytecode. It provides an abstraction layer between the Java code and the underlying operating system, enabling platform independence.
  • Java Class Libraries: The JRE contains the core Java class libraries, which provide pre-compiled classes and methods for common programming tasks. These libraries are essential for running Java applications.

In summary, the JRE is used by end-users who only need to run Java applications without needing development or compilation.

JVM (Java Virtual Machine)

The JVM is an integral part of the Java platform and is responsible for executing Java bytecode. It provides a runtime environment in which Java applications can run. The JVM performs the following key functions:

  • Bytecode Execution: The JVM interprets the Java bytecode line by line and executes the corresponding instructions.
  • Memory Management: The JVM manages memory allocation and deallocation, including garbage collection, to free up memory occupied by objects no longer in use.
  • Platform Independence: The JVM provides platform independence by interpreting the bytecode and translating it into machine code specific to the underlying operating system.

In summary, the JVM is the runtime engine responsible for executing Java applications and ensuring their portability across different platforms.

Java Interview HandbookJava

Gopi Gorantala Twitter

Gopi is an engineering leader with 12+ of experience in full-stack development—a specialist in Java technology stack. He worked for multiple startups, the European govt, and FAANG in India and Europe.


Related Posts

Members Public

Difference Between String and char[] in Java

Short answer Strings String is an object with many helpful methods. String class in Java's standard library is designed to handle text as a sequence of characters. A string of characters (string object) is non-modifiable or immutable in Java. Once you've created it, you cannot modify

Members Public

What is an Object class in Java?

Short answer Object class is the super class of every class you can create. In Java, a class extends another class using the keyword extends. If you don't have any other class to extend, that's fine. The compiler will make your class extend the Object class.

Members Public

What is the JVM? With Sketches and Examples

Short answer JVM stands for Java Virtual Machine. JVM is a virtual machine( a piece of software) that executes Java bytecode. It provides a runtime environment for executing Java applications. The above sketch explains how the same bytecode is run across multiple virtual machines on different operating systems. If someone