Open In App

JRE in Java

Java Runtime Environment (JRE) is an open-access software distribution that has a Java class library, specific tools, and a separate JVM. In Java, JRE is one of the interrelated components in the Java Development Kit (JDK). It is the most common environment available on devices for running Java programs. Java source code is compiled and converted to Java bytecode. If you want to run this bytecode on any platform, you need JRE. The JRE loads classes check memory access and get system resources. JRE acts as a software layer on top of the operating system.

Components of Java JRE

The components of JRE are mentioned below:



Components of Java Runtime Environment (JRE)

Java Virtual Machine (JVM) consists of Java HotSpot Client and Server Virtual Machine.

Working of JRE

Java Development Kit (JDK) and Java Runtime Environment (JRE)  both interact with each other to create a sustainable runtime environment that enables Java-based applications to run seamlessly on any operating system. The  JRE runtime architecture consists of the following elements as listed:



  1. ClassLoader
  2. ByteCode verifier
  3. Interpreter

Now let us briefly about them as follows:

How does JRE work with JVM?

Working of JRE

JRE has an object of JVM with it, development tools, and library classes. To understand the working of Java Runtime Environment let us see an example of a simple Java program that prints  “GeeksForGeeks”. 

Example:




// Java class
class GFG {
   
    // Main driver method
    public static void main(String[] args) {
       
        // Print statement
        System.out.println("GeeksForGeeks");
    }
}

Output
GeeksForGeeks

Once you write your Java program, you must save it with a file name with a “.java” extension. Then after you Compile your program. The output of the Java compiler is byte code which is a platform-independent code. After compiling, the compiler generates a .class file that contains the byte code. Bytecode is platform-independent that runs on all devices which contain Java Runtime Environment (JRE).

Difference between JVM, JRE, and JDK.

Article Tags :