Difference between JDK, JRE and JVM

7/28/2021

difference between jdk jre and jvm #JDK #JRE #JVM #java #difference #between

Go Back

Difference Between JDK, JRE, and JVM: A Comprehensive Guide

In this article , we discribe the differences between JDK, JRE, and JVM in Java. Understand the internal architecture of JVM and their roles in Java development and execution.
JDK (Java Development Kit) is for developers, including JRE and tools for building Java applications; JRE (Java Runtime Environment) is for running Java applications, containing JVM and libraries; and JVM (Java Virtual Machine) is the platform-independent environment that executes Java bytecode.

Introduction to JDK, JRE, and JVM

When working with Java, understanding the difference between JDK, JRE, and JVM is crucial. These three components form the backbone of Java programming, enabling developers to write, compile, and run Java applications. In this article, we’ll explore what JDK, JRE, and JVM are, their differences, and the internal architecture of JVM.

difference between jdk jre and jvm   #JDK  #JRE  #JVM #java #difference #between

What is JVM (Java Virtual Machine)?

The Java Virtual Machine (JVM) is a runtime engine that provides an environment to execute Java bytecode. It is platform-dependent, meaning JVM implementations vary across operating systems. However, Java itself is platform-independent, thanks to JVM.

Key Responsibilities of JVM:

  1. Loads Code: Reads the bytecode from .class files.
  2. Verifies Code: Ensures the bytecode is valid and secure.
  3. Executes Code: Converts bytecode into machine-specific instructions.
  4. Provides Runtime Environment: Manages memory and system resources.

For more details, refer to the official JVM documentation.

Internal Architecture of JVM

The JVM architecture consists of several components that work together to execute Java programs:

  1. ClassLoader: Loads .class files into memory.
  2. Class (Method) Area: Stores class-level data like runtime constant pools, method code, and field data.
  3. Heap: A runtime data area where objects are allocated.
  4. Stack: Stores frames for methods. Each frame holds local variables and partial results.
  5. Program Counter (PC) Register: Tracks the address of the currently executing instruction.
  6. Native Method Stack: Manages native methods written in languages like C or C++.
  7. Execution Engine: Consists of:
    • Interpreter: Executes bytecode line by line.
    • Just-In-Time (JIT) Compiler: Converts bytecode into native machine code for faster execution.

What is JDK (Java Development Kit)?

The Java Development Kit (JDK) is a software development environment used to develop Java applications. It includes:

  • JRE (Java Runtime Environment): For running Java applications.
  • Development Tools: Such as javac (Java compiler), java (Java interpreter), and debugging tools.

The JDK is essential for developers who need to write, compile, and debug Java code. For more details, visit the official JDK documentation.

What is JRE (Java Runtime Environment)?

The Java Runtime Environment (JRE) provides the runtime environment for executing Java applications. It includes:

  • JVM: For executing bytecode.
  • Libraries: Essential Java class libraries and supporting files.

The JRE is used by end-users who only need to run Java applications. For more details, refer to the official JRE documentation.

Key Differences Between JDK, JRE, and JVM

Component Full Form Purpose Contains
JDK Java Development Kit Used for developing Java applications. JRE + Development tools (e.g., javac, java, debuggers).
JRE Java Runtime Environment Provides the runtime environment for executing Java applications. JVM + Libraries and supporting files.
JVM Java Virtual Machine Executes Java bytecode and provides a runtime environment for Java programs. ClassLoader, Memory Areas (Heap, Stack), Execution Engine, Native Methods.

Conclusion

In this article, we explored the difference between JDK, JRE, and JVM and their roles in Java development and execution. We also delved into the internal architecture of JVM, understanding how it loads, verifies, and executes Java bytecode.

Whether you're a beginner or an experienced developer, mastering these concepts is essential for building and running Java applications. Stay tuned for more updates, and don’t forget to follow us on Instagram and Facebook for the latest tutorials and tips!

 

Table of content