In the previous tutorial, we knew that the three main components of the Java platform are the Java Virtual Machine (JVM), the Java Runtime Environment (JRE) and the Java Development Kit (JDK).
The Java Runtime Engine (JRE) is the software environment in which a Java program runs.
In other words: JRE is a software environment required to run Java applications on any system, regardless of the underlying operating system and hardware.
The JRE is part of the Java Development Kit, but it cannot be used alone to execute the bytecode (the compiled Java program). It cannot be used to develop programs for Java applications, but can be used to run them.
The Java Runtime Environment is a collection of programs that contains the Java Virtual Machine and many of the class library files needed to run programs on the JVM (using the java command).
If you have a modern JDK (Java Development Kit) installed on your computer system, you do not need to reinstall it.
The Java Development Kit also includes the Java Runtime Environment (JRE), which allows you to run Java programs in Eclipse on your system.
Java Runtime Environment (JRE) components
The JRE consists of the following main elements:
- Java API (Application Programming Interface)
- Nice forklift.
- Bytecode checker
- Java virtual machine (interpreter)
Look at the diagram below to understand the components of the JRE.
Let’s give a short description of each JRE component.
What is a Java API (Application Interface Programming)?
The Java Application Programming Interface (API) is a very large collection of standard software components that provide the core functionality of the Java programming language.
Simply put, a Java API is a large collection of classes, interfaces, and methods already defined as Java packages.
It offers programmers many useful features, such as a graphical user interface (GUI), date, time and calendar.
The Java API is grouped into libraries of related classes and interfaces and their fields, constructors, and methods. These libraries are offered as packages.
It provides additional programming capabilities based on the Java kernel platform. This means that the basic characteristics of the Java programming language do not change when a new version is released.
Since the Java API is flexible, it can be opened up to add new packages or libraries.
Here are some popular libraries and their functionality of the Java API, in brief:
(a) Java.lang : It is a package that provides basic classes for designing the Java programming language. The Java.lang package is dynamically imported (i.e. loaded) into the Java program. There is no need to enter it explicitly.
The most commonly used classes in the Java.lang package are Double, Float, Integer, String, StringBuffer, System, and Math.
(b) Java.io: Support for I/O via file system, keyboard, network, etc. The java.io package contains several classes to perform input and output operations.
The most commonly used classes in java.io are the File class, InputStreams, OutputStreams, Readers, Writers, and RandomAccessFile.
(c) Java.util : Supports various programming tools. The java.util package provides inherited collection classes, an event model, a collection framework, date and time functions, and other utilities such as the string tokenizer.
(d) Java. Math: Used to support arithmetic operations.
(e) Java.security : Supports security features.
(f) Java.awt : Allows you to create graphical user interfaces (GUIs), draw pictures and charts.
g) Java.sql : Supports accessing relational databases via SQL.
(h) Java. Beans: It supports the creation of Java Beans.
(i) Java.net : The java.net package contains classes that can be used to implement networking in Java programs.
j) Java.imageIO : Support for image input/output.
These predefined Java APIs provide the programmer with a lot of basic functionality. The programmer needs to know these Java APIs. He needs to know how to use these Java APIs.
These are examples of some of the important libraries in the Java API. We’ll talk more about these libraries in the next tutorial.
For a complete list of Java API classes, see the Oracle Web site: https://docs.oracle.com/javase/7/docs/api/.
What is a class loader in Java?
When we write a program in Java, the class loader places the program in memory before it can be executed.
The Java Class Loader takes a .class file that contains bytecode and transfers it to memory. It downloads the .class file from your system’s hard drive or over the network.
Once the class is loaded, it is passed to the bytecode checker.
There are essentially three subcomponents of a class loader in Java. They are as follows:
- Bootstrap class loader
- Charger class expansion
- System class charger
a) Bootstrap class loader :
The bootloader loads the main Java libraries located in C:Program FilesJavajre1.8.0_181lib. The contents of this directory in a JRE8 environment are shown in the following figure.
You can clearly see different *.jar files, such as charsets.jar, deployment.jar, javaws.jar, plugin.jar, etc.
b) Charger extension class :
The extension’s class loader loads classes from the extension directory C:Program FilesJavajre1.8.0_181libext. The following screenshot shows the contents of the Extensions directory in a JRE8 environment.
As you can see in the screenshot above, there are several JAR files available: access-bridge-64.jar, localedata.jar, etc. You can also see how it goes to the location above the path.
(c) Charger system class :
The System Class Loader loads the code from the location specified in the CLASSPATH environment variable set by the operating system, as shown in the following figure.
It can be found in Windows 10 under Control Panel ⇒ System and Security ⇒ System, Advanced System Settings ⇒ Advanced Tabs ⇒
Environment Variables.
What is a bytecode checker?
The bytecode checker checks whether the bytecodes are valid or not, without violating any of Java’s security rules. Particular attention is paid to checking the type of all variables and expressions in the code.
The bytecode checker ensures that no unauthorized access to the memory is possible. After successful verification, the code is passed to the Java Virtual Machine (JVM) for interpretation.
Message: We can choose to disable bytecode checking (which allows for slightly faster execution), enable it only for code loaded remotely from the network, or enable it for all code.
We hope this tutorial has covered all the basic concepts related to the Java Runtime Environment (JRE) and its main components. I hope you understood the basics of JRE.
In the next lesson, we will learn about the Java Virtual Machine (JVM).
Thanks for reading!!!
frequently asked questions
What is a class loader in the JVM?
Class loaders are responsible for dynamically loading Java classes into the JVM (Java Virtual Machine) at runtime. They are also part of the JRE (Java Runtime Environment). Thus, with class loaders, the JVM does not need to know anything about the underlying files or file systems to execute Java programs.
What is dynamic class loading in Java?
Dynamic class loading allows Java code to be loaded that is not known before the program is executed. The Java model loads classes as needed and does not need to know the names of all the classes in the collection before any of the classes are loaded and executed. … You can create an object at runtime by dynamically loading classes.
What is a load class in C#?
The class loader is responsible for loading the class after checking the metadata. … The class is loaded for execution only if the resources are available on the client computer and the version and security token of the DLL match the metadata.
Related Tags:
java class loader example,java load class at runtime,java class loader hierarchy,types of class loader in java,java create new class loader,java dynamic class loading from jar,Feedback,Privacy settings,How Search works,class loader error in java,which of the following statements about java class loader is true