What is the JVM? (Java Virtual Machine)

JVM is a virtual machine that enables computer device to run Java programs and programs written in other languages and compiled to Java bytecode,virtual machine that runs Java class files in a portable way in such a way being a virtual machine means the JVM is an abstraction of an underlying, actual machine such as the server that your program is running on.
Technical definition: The JVM is the specification for a software program that executes code and provides the runtime environment for that code.

Everyday definition: The JVM is how we run our Java programs. We configure the JVM’s settings and then rely on it to manage program resources during execution.

When developers talk about the JVM, they usually mean the process running on a machine, especially a server, that represents and controls resource usage for a Java app. Contrast this to the JVM specification, which describes the requirements for building a program that performs these tasks.

JVM (Java Virtual Machine) has two main primary functions: 

1. To allow Java programs to run on any device or operating system (known as the “Write once, run anywhere” principle), and 
2. To manage and optimize program memory. 
When Java was released in 1995, all computer programs were written to a specific operating system, and program memory was managed by the software developer. So the JVM was a revelation.

Internal Architecture of Java Virtual Machine

This is a subsystem of JVM that is used to load the class files.
Java Stack stores frames. It holds local variables and partial results, and plays a part in method invocation and return.
Class(Method) Area
Stores per-class structures such as the runtime constant pool, field and method data, the code for methods.
Native Method StackThe native Method Stack contains all the native methods used in the application.
It is the runtime data area in which objects are allocated.
Program Counter Register
PC (program counter) register contains the address of the Java virtual machine instruction currently being executed.
Each thread has a private JVM stack, created at the same time as thread.
A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.
Execution Engine
The execution Engine contains:
1) A virtual processor
2) Interpreter: Read bytecode stream then execute the instructions.
3) Just-In-Time(JIT) compiler.
JIT compiler. is used to improve the performance, it compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.

Leave a Reply

Your email address will not be published. Required fields are marked *