Component Responsible for Running a Java Program



Java Runtime Environment (JRE)

JRE is a part of the Java Development Kit (JDK), which is responsible for executing a Java program. It acts as a mediator between the Java program and the OS. This allows the Java program to run on any system that has a compatible JRE installed. JRE contains components like JVM, class libraries, class loaders, and other libraries.

Major Components of JRE

Java Virtual Machine (JVM)

JVM is the main component of the Java Runtime Environment. It performs the execution of the bytecode generated by the compiler and also serves as an interpreter, converting the bytecode into machine language. It is essential for memory management and garbage collection, which frees up the memory that is no longer in use. JVM also includes JIT (Just-In-Time compiler), which helps to convert bytecode to machine code during run time.

Java class Libraries

Java class libraries are prewritten, ready to use code that can be used in a lot of work such as file handling, interaction with system I/O, and networking, development of graphical user interface, data communications and safety, and databases. When creating an application, developers can save a lot of time and work by using these pre-built components from these libraries.

Class loaders

Class loaders in JRE are in charge of bringing Java classes into the JVM during runtime. Instead of loading all the classes at start-up, this enables the application to load them effectively as needed on demand. This increases performance and memory management in applications.

How is the Java program being executed?

When a Java program is compiled by the Java compiler, it is translated into an intermediate language called bytecode that is platform-independent. The Java class loader loads the necessary files into the memory. These class files contain the bytecode instructions of the program. The JVM, then, checks the bytecode's integrity and safety. This prevents malicious code from being executed and compromising the system. Once the bytecode is verified, the JVM executes the bytecode, manages memory allocation, garbage collection, and other runtime operations.

The following line explains how the source code is converted into machine code.

Source code->Java compiler->Bytecode->Class Loader->Bytecode Verifier->JIT Compiler->Machine code

JDK vs JRE vs JVM

JDK

The JDK provides the entire development environment for Java programmers, who get all the tools and libraries within this environment to develop, compile, debug, and run their Java applications. Essential components in the JDK system include the following ?

  • Java Compiler (javac) ? Converts Java source code into bytecode, which is the intermediate language that the Java Virtual Machine (JVM) understands.
  • Java Runtime Environment (JRE) ? Delivers core functionality for the execution of Java programs.
  • Java Virtual Machine (JVM) ? The primary element of the JRE, which is responsible for executing Java bytecodes in different operating systems.
  • Debugging tools ? Assist developers to locate and eliminate errors in their code.
  • Documentation and tutorials ? Useful resources to learn and use the Java platform.

JDK = Java Runtime Environment (JRE) + Compiler + Development tools

JRE

JRE is a subset of the JDK specifically used to run java programs. It includes the following components ?

  • JVM ? The core part that executes Java bytecode
  • Java Class Library ? Contains a pre-written collection of classes in Java that gives essential functionality like input/output, networking, data structures, etc.
  • Class loaders ? They are responsible for bringing Java classes into the JVM on demand.

JRE is sufficient enough for running Java applications. But in order to develop them, other components in JDK are required.

JRE = Java Virtual Machine (JVM) + Libraries to run the application

JVM

The JVM is the heart of Java, which operates to execute Java bytecode on any operating system that supports a JVM implementation. Below are three main points concerning the JVM ?

  • Platform independence ? the JVM is an intermediary between the operating system and the Java program, which enables the 'write once, run anywhere' functionality.
  • Memory management ? The memory allocation and garbage collection tasks are automatically handled by JVM, rather than relying on manual memory management tasks.
  • Security ? The JVM comes with security features like bytecode verification to prevent malicious code execution.

JVM = Runtime environment for executing the Java bytecode.

Check out this link for knowing more about difference between JDK, JRE and JVM.

Updated on: 2025-03-30T12:59:46+05:30

201 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements