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:
- Integration libraries include Java Database Connectivity (JDBC)
- Java Naming, Interface Definition Language (IDL)
- Directory Interface (JNDI)
- Remote Method Invocation Over Internet Inter-Orb Protocol (RMI-IIOP)
- Remote Method Invocation (RMI)
- Scripting
Components of Java Runtime Environment (JRE)
Java Virtual Machine (JVM) consists of Java HotSpot Client and Server Virtual Machine.
- User interface libraries include Swing, Java 2D, Abstract Window Toolkit (AWT), Accessibility, Image I/O, Print Service, Sound, drag, and Drop (DnD), and input methods.
- Lang and util base libraries, which include lang and util, zip, Collections, Concurrency Utilities, management, Java Archive (JAR), instrument, reflection, versioning, Preferences API, Ref Objects, Logging, and Regular Expressions.
- Other base libraries, including Java Management Extensions (JMX), Java Native Interface (JNI), Math, Networking, international support, input/output (I/O), Beans, Java Override Mechanism, Security, Serialization, extension mechanism, and Java for XML Processing (XML JAXP).
- Deployment technologies such as Java Web Start, deployment, and Java plug-in.
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:
- ClassLoader
- ByteCode verifier
- Interpreter
Now let us briefly about them as follows:
- ClassLoader: Java ClassLoader dynamically loads all the classes necessary to run a Java program. Because classes are only loaded into memory whenever they are needed, the JRE uses ClassLoader will automate this process when needed. During the initialization of the JVM, three classLoaders are loaded:
- Bootstrap class loader
- Extensions class loader
- System class loader
- Bytecode Verifier: The bytecode checker ensures the format and precision of Java code before passing it to the interpreter. If the code violates system integrity or access rights, the class is considered corrupt and will not load.
- Interpreter: After loading the byte code successfully, the Java interpreter creates an object of the Java virtual machine that allows the Java program to run natively on the underlying machine.
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
// Java class
class GFG {
// Main driver method
public static void main(String[] args) {
// Print statement
System.out.println("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.
- JVM: JVM stands for Java Virtual Machine. JVM is used for running Java bytecode.Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one system and can expect it to run on any other Java-enabled system without any adjustment. This is all possible because of JVM.
- JRE: JRE stands for Java Runtime Environment. JRE is made up of class libraries.
- JDK: JDK stands for Java Development Kit. JDK contains the JRE with compiler, interpreter, debugger, and other tools. It provides features to run as well as develop Java Programs.
Similar Reads
JDK in Java The Java Development Kit (JDK) is a cross-platformed software development environment that offers a collection of tools and libraries necessary for developing Java-based software applications and applets. It is a core package used in Java, along with the JVM (Java Virtual Machine) and the JRE (Java
5 min read
Java IO Tutorial Java programming language comes with a variety of APIs that helps the developers to code more efficiently. One of those APIs is Java IO API. Java IO API helps the users to read and write data. In simple words, we can say that the Java IO helps the users to take the input and produce output based on
15+ min read
Java.lang package in Java Java.lang package in JavaProvides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time. Following are the Important Classes in Java.lan
3 min read
Java SE vs Java EE Java is a highly popular and versatile programming language used globally to create various applications. Two major Java platforms are Java SE (Standard Edition) and Java EE (Enterprise Edition). Understanding the differences between these platforms is crucial for developers working on enterprise-le
5 min read
Java Cheat Sheet Java is a programming language and platform that has been widely used since its development by James Gosling in 1991. It follows the Object-oriented Programming concept and can run programs written on any OS platform. Java is a high-level, object-oriented, secure, robust, platform-independent, multi
15+ min read
Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android
4 min read