How the JRE Works

In this article we'll understand how the JRE works.
 
First let's learn the difference between the JVM, JRE, and JDK.
 
The Java Virtual Machine (JVM) is an abstract machine. It is a specification that provides a runtime environment in which the Java Byte Code is executed.
 
The JVM is platform-independent, in other words it is available for many software and hardware platforms.
 
The Java Runtime Environment (JRE) provides a runtime environment and is the implementation of the JVM. It exists physically. It contains a set of libraries and other files that the JVM uses.
 
The Java Development Kit (JDK) also exists physically and contains the JRE with development tools.
 
Now to understand how the JRE works let us consider a Java source file saved as Example.java. The file is compiled into a set of Byte Code that is stored in a ".class" file. Here it will be "Example.class".
 
The following diagram depicts what is done at compile time.
 
JRE 
 
The Byte Code in the class file is non-readable code.
 
The following actions take place at runtime.
 

Class Loader

 
The Class Loader loads all necessary classes needed for the execution of a program. It provides security by separating the namespaces of the local file system from that imported through the network. These files are loaded either from a hard disk, a network or from other sources. 
 

Byte Code Verifier

 
The JVM puts the code through the Byte Code Verifier that checks the format and checks for illegal code. Illegal code for example is code that violates access rights on objects or violates the implementation of pointers.
 
The Byte Code verifier ensures that the code adheres to the JVM specification and does not violate system integrity.
 
Byte Code Verifier 
 

Interpreter

 
At runtime the Byte Code is loaded, checked and run by the interpreter. The interpreter has the following two functions:
  1. Execute the Byte Code
  2. Make appropriate calls to the underlying hardware
Both operations can be shown as:
 
Interpreter 
 
Thanks , I hope it will be helpful to you.


Similar Articles