Skip to main content

Java Internals

JDK, JRE, and JVM

JDK, JRE, and JVM are essential components of the Java platform, each serving a distinct purpose.

Before we learn more about each one, here is a blueprint showing 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
     |    |
     |    +--- java.io Package
     |    |
     |    +--- java.util Package
     |    |
     |    +--- ...
     |
     +--- Java Standard Extensions
          |
          +--- JavaFX
          |
          +--- Java Accessibility
          |
          +--- Java Cryptography Extension (JCE)
          |
          +--- ...

Sketch

So, where do the JDK, JRE, and JVM reside? How is the JDK bundled? Let's see a simple sketch that explains what JDK is, how it is bundled, and where the JVM exists. This gives you clarity on how JDK-JRE-JVM is connected.

JDK sketch, including all pieces of software. The only important ones are shown here:

JDK (Java development kit)

The JDK is used by developers to write, compile, and debug Java code.

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)

End-users use the JRE to run Java applications.

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 the runtime engine that executes Java bytecode, and it is included in both the JDK and the JRE.

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.