What is Java Runtime Environment?

Java runtime environment is part of the JDK software. It is mandatory to download the JDK software before running a Java application on any device. After downloading the JDK, the software takes two formats. They include,

1) The Developer Environment

2) The Java Runtime Environment

What is the Role of Developer Environment in Java?

 


The Developer Environment is responsible for


a) Program compilation and


b) Generation of a dot class file


C) Finally, check the semantics and syntax errors of the Java program.


Notably, the development environment ensures that the dot class file is free of syntax errors during its generation.


After performing the above three tasks, the working of the developer environment ends here.



What is the role of Java Runtime Environment?

 


The runtime environment will 


a)     Take the dot class file from the developer environment and 

b)     Run and generate the instructions required by the underlying architecture.

 


An Overview of JRE
Java Runtime Environment (JRE)

What does the Development Environment and Runtime Environment Contain?


The Java runtime environment consists of an 

 

  • Interpreter and another tool known as 
  • JIT (Justin time compiler). 
  •  

Similarly, the JDK consists 

  • JVM (Java Virtual Environment)

Notably, the interpreter is not within the developer environment. This means we are using it for compilation. The JVM (Java Virtual Machine) will be installed during JDK installation.


 

Who will Generate the Dot Class File?

 

The JVM inside the JDK generates the dot class file. 

With the JVM inside the JDK, calling JDK means you are calling JVM.

 

How to Call the Development Environment in Java?

 

While compiling the program, we write JavaC along with file name,


for example as Javac D.java 


Here, javac means Java compiler.

 

By using javac, it invokes the JVM, telling the developer environment to compile the program and ensure that there are no errors. 


After that, the source code is converted into machine-readable code called employee. class


 

Execution of Class File

 

However, the microprocessor will not directly execute this class file because it is in byte code. 


The byte code, which is in 8-bit format, must be converted into a format compatible with the underlying architecture.


For example, if the underlying microprocessor is 16-bit, 32-bit, or 64-bit, the byte code (8-bit) should convert into 16, 32, or 64-bit. 


Who will convert the Byte Code into Code Compatible with the Microprocessor?

The Java runtime environment converts the 8-bit into 16-bit, 32-bit, or 4-bit.

Consequently, the importance of the interpreter at this stage is greater than that of the interpreter part of JVM.


What does the Java Virtual Machine actually do?

When typing the javac (we are invoking the Java compiler) (JVM) Means the

development environment.


The code reaches the JVM, then it develops the environment, compiles the program, and ensures that there are no errors. Finally, it generates the dot class file. 


 

Next, if we write Java along with the file name, i.e., Java Employee (we are invoking the JRE), it reaches the runtime environment through the JVM.

 


Both the comments are above the heap. Both the commands are used by the JVM. First, to compile the program and secondly to hand over the dot class file to the Java runtime environment.


JVM takes the javac and compiles it to generate the byte code.


And JVM takes the Java and gives it to the JRE.


What is an Actual Machine?


The instruction format of a dot exe file is known as an actual machine.


While compiling a program, the compiler generates an instruction format or dot exe file whose instructions are in a microprocessor-specific format. In other words, the compiler is going to generate instructions that are actually required by the microprocessor.


It means if the microprocessor is 16-bit, the dot exe file format is 16-bit instruction bit. If 34-bit, the dot class file format is 34-bit instruction set.


In structured programming, such as C, the compilers generate the instructions the microprocessor actually requires. That is called the actual machine.


What is a Virtual Machine?


In Java, you are compiling the dot java file. Through javac, the dot Java file is converted into byte code, which has an instruction format of 8 bits, regardless of the underlying architecture.  Such a type of conversion is known as a virtual machine.

A virtual machine does not generate the actual instructions but generates intermediate instructions.


 

Advantages of Virtual Machine

 


Due to the inclusion of a virtual machine in Java, we can run the Java program on any gadget, such as a watch, mobile phone, laptop, tablet, or tablet.

 


Steps involved in Compilation to Running of the Java Program:

 

While compiling the Java program, we write javac and Java. While javac is for developer environment, Java is for runtime environment.


javac invokes the JVM to fetch the dot class file from the external hard disk or secondary environment into the Java Runtime environment.


  • From the Java Runtime Environment through the interpreter, 
  • convert the eight-bit instruction into microprocessor-specific instruction format. 
  • Then, store the instruction in the RAM inside the heap. 

  • The moment the data enters the RAM or the heap, there is a state change, 

Whenever there is a state change, the operating system will come and read the newly arrived bytes. It will then perform actions according to the instructions while using the microprocessor for processing.

 


Discover more from BerylSoft

Subscribe now to keep reading and get access to the full archive.

Continue reading