No announcement


When you run a Java program, it does not get directly executed by the Operating system, rather it is loaded and then executed by a Java Virtual Machine (JVM). Operating system compatible Java Runtime Environment (JRE) needs to be downloaded and installed in order to facilitate the execution of Java programs.

The following figure represents Java architecture:

Java Architecture

We write the code in a form understandable by us (called the source code). Then compiles the code using compiler. The Compiler takes as input the source code and converts it into a form understandable by the Java virtual machine (JVM), i.e., byte code. This byte code is further converted into machine code by the JVM and executed by the execution engine to produce the desired output.

JVM Architecture

Details of the components of JVM:

  1. Class loader
    The class loader subsystem is used for loading class files. Primary function is Loading, Linking and Initialization.
  2. JVM Memory
    a. Method Area
    Class level information is stored here, like class name, parent class name, method and variable information.
    b. Heap
    Information of all the objects is stored here. Heap is created during JVM start-up.
    c. JVM Language Stack
    One runtime stack is created for every thread, which is stored here. Every block of the stack stores method call and all the local variable of that particular method are stored in its corresponding frame.
    d. PC Register
    It stores the address of the current execution instruction.
    e. Native Method Stack
    It stores the native method information. 
  3. Execution Engine
    It executes the bytecode.
  4. Native Method Interface
    This provides interacts with the native method libraries and provides the native libraries for the execution.
  5. Native Method Libraries
    It is a collection of native method libraries (written in any other programming language other than Java).