It is very important to understand what JDK, JRE, and JVM are in Java.
In this chapter, we will have a brief discussion about these terms.
There are two principal products in the Java SE platform family:
Java SE Runtime Environment (JRE)
Java Development Kit (JDK)
Java Development Kit (JDK) provides the environment to develop and execute (run) Java programs.
JDK contains two parts:
1. Utilities like javac
, debugger, jar
— used to compile source code (.java
files) into bytecode (.class
files) and debug programs.
2. The JRE, which contains utilities like java
to run/execute the bytecode.
You need JDK if you want to write and compile your own programs. For only running Java programs, JRE is sufficient.
The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine (JVM), and other components to run (not develop) Java applets and applications.
A Java Virtual Machine (JVM) is an abstract computing machine that enables a computer to run a Java program.
JVMs are available for many hardware and software platforms (i.e., JVM is platform-dependent).
JVM (Java Virtual Machine) is software — a specification that provides the runtime environment to execute Java bytecode. It does not physically exist.
There are three notions of the JVM:1. Specification: A formal document describing what is required of a JVM implementation. Ensures all implementations are interoperable.
2. Implementation: A computer program that meets the JVM specification.
3. Instance: A running implementation in a process that executes Java bytecode.
As shown in the JVM architecture diagram, JVM is divided into three main subsystems:
1. Class Loader Subsystem
2. Runtime Data Area
3. Execution Engine
The Class Loader loads class files and performs three basic activities in strict order:
1.1. Loading: Finds and imports the binary data for a type.
1.2. Linking: Performs verification, preparation, and (optionally) resolution.
1.3. Initialization: Invokes Java code to initialize class variables to their proper starting values.
There are two types of class loaders: bootstrap class loader and user-defined class loader. Every JVM must have a bootstrap class loader for trusted classes.
The Runtime Data Area is divided into 5 major components:
2.1 Method Area – Stores class-level data (including static variables). Shared across JVM, one per JVM.
2.2 Heap Area – Stores objects, instance variables, and arrays. One per JVM. Not thread-safe since it’s shared.
2.3 Stack Area – Each thread gets its own runtime stack. Each method call creates a stack frame containing local variables.
2.4 PC Registers: Each thread has its own PC register holding the address of the current instruction.
2.5 Native Method Stacks: Each thread gets its own stack for native method information.
The Execution Engine executes bytecode assigned to the Runtime Data Area. It contains:
1. A Virtual Processor
2. Interpreter: Reads and executes bytecode instructions.
3. JIT Compiler: Improves performance by compiling frequently used bytecode into native code for faster execution.
Topic: Jdk_jre_jvm | Language: Java