Java Virtual Machine (JVM) architecture

You would want to learn full details of how JVM really functioning. In this post, I'm going to explain JVM (Java Virtual Machine) architecture

What is JVM

A description where working of Java Virtual Machine is detailed. But implementation provider is independent to select the algorithm. Its implementation has been provided by Sun and other companies.

An implementation Its implementation is known as JRE (Java Runtime Environment).

Runtime Instance Whenever you write java command on the command prompt to run the java class, and instance of JVM is created.

What it does?

The JVM performs following operation:

  • Loads code
  • Verifies code
  • Executes code
  • Provides runtime environment

JVM provides definitions for the:

  • Memory area
  • Class file format
  • Register set
  • Garbage-collected heap
  • Fatal error reporting etc.


JVM has various sub components internally. You can see all of them from the above diagram.

1. Class loader sub system: JVM's class loader sub system performs 3 tasks
      a. It loads .class file into memory.
      b. It verifies byte code instructions.
      c. It allots memory required for the program.

2. Run time data area: This is the memory resource used by JVM and it is divided into 5 parts
      a. Method area: Method area stores class code and method code.
      b. Heap: Objects are created on heap.
      c. Java stacks: Java stacks are the places where the Java methods are executed. A Java stack contains frames. On each frame, a separate method is executed.
      d. Program counter registers: The program counter registers store memory address of the instruction to be executed by the micro processor.
      e. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed. Native method is a function, which is written in another language other than Java.

3. Native method interface: Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods.

4. Native method library: holds the native libraries information.

5. Execution engine: Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler. The HotSpot represent the block of code executed by JIT compiler.
  1. A virtual processor
  2. Interpreter: Read bytecode stream then execute the instructions.
  3. Just-In-Time(JIT) compiler: It is used to improve the performance.JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term ?compiler? refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.