1. Overview
For a newcomer to the world of Java development, one of the most common sources of confusion is the distinction between the terms JRE, JDK, and JVM.
In this article, we’ll look at these different concepts and show you their usefulness in the Java ecosystem.
2. JRE
JRE stands for Java Runtime Environment. This is the execution environment for Java programs. Simply put, you can’t run Java programs on a workstation without a JRE. The JRE provides a set of libraries, the virtual machine (JVM), and useful components for running Java applications.
JRE components
- Java Virtual Machine (JVM): Executes Java bytecode
- JRE Class Library: Precompiled classes and methods used during runtime
3. JDK
JDK stands for Java Development Kit. It’s the Java Developer’s Kit. You can’t compile a Java program on a workstation without JDK. The JDK contains the JRE, plus the tools needed to compile and debug Java applications.
JDK Components
- Compiler: Converts Java source code into bytecode.
- Java Runtime Environment (JRE): Includes libraries and binaries for running Java applications.
- Debugger: Helps in debugging Java code.
- Other Development Tools: Profilers, Javadoc (documentation generator), etc.
4. JVM
The JVM is a virtual machine that provides an execution environment for Java bytecode. JVM is part of the JRE and is responsible for the following :
- Bytecode Execution: Converts Java bytecode into machine-specific code for execution.
- Memory Management: Manages memory allocation and garbage collection.
- Security: Provides a secure execution environment.
JVM Components
Some of the main components of the Java Virtual Machine are :
- Class Loader: Loads Java classes into the memory dynamically during runtime
- Bytecode Verifier: Verifies the integrity and safety of the bytecode before execution
- Interpreter: Interprets and executes the Java bytecode line by line
- Just-In-Time (JIT) Compiler: Translates Java bytecode into native machine code just before execution
- Execution Engine: Executes the Java bytecode by using the interpreter or the Just-In-Time compiler
5. To sum up
In summary, the JDK is for Java development and includes the JRE necessary for running Java applications.
The JVM is a crucial component of both the JDK and JRE, responsible for executing Java bytecode on different platforms.
Pingback: JDK Installation Guide for macOS, Linux, and Windows