Java Runtime Environment (JRE) is a software layer that runs on top of a computer’s operating system, providing additional services that a specific Java program needs to run. JRE is one of three interrelated components that form a trifecta for developing and running Java applications. The other two are:
- Java Development Kit (JDK): A set of tools for developing Java applications. JDKs are chosen by developers by Java version and edition, such as the Java Enterprise Edition. Regardless of version or edition, JDK always includes a compatible JRE.
- Java Virtual Machine (JVM): Executes live Java applications. Every JRE includes a default JVM.
JRE combines Java code created using the JDK with the libraries required to run it on a JVM. Then, an instance is created of the JVM that executes the resulting program.
JRE provides many integration libraries such as Java IDL, Java Database Connectivity, and Java Naming and Directory Interface to help developers create seamless data connections between applications and services. JRE also includes packages that are foundational for the design of applications. Some packages include collections framework, concurrency utilities, preferences API, and Java Archive.
How the Java Runtime Environment works
To create a runtime environment, JDK and JRE interact to enable a smooth execution of Java-based applications within any operation system. The following processes take place at runtime:
The Java ClassLoader dynamically loads all necessary classes needed to run a Java program. It provides security by separating namespaces of the local file system from what’s imported through the network. Since Java classes are only loaded into memory when it’s required, the JRE uses ClassLoader to process this demand.
The bytecode verifier ensures the format and accuracy of Java code before it’s passed to the interpreter. It also checks for illegal code, which is code that violates access rights on objects or violates the implementation of pointers. If a code is in violation, the class will be considered corrupted and will not be loaded.
After the bytecode is successfully verified, at runtime it is loaded, checked, and run by the interpreter. The interpreter creates an instance of the JVM that allows the program to be executed natively on the underlying hardware.