Posts Tagged Java

Overview of Java Virtual Machine

Monday, May 9th, 2011

By: Jatin Chawla

Java Virtual Machine

We know that every work/task has two and more than two forms that are interrelated with one another. For example: A tape is in two forms that are analog and digital; A person also is in two forms that are passive and active; Every application is in two forms Setup files and installed files. These forms are converted from one to another by through a particular converter/translator. In similar way, Java program must be converted from Source code to Machine code.

Most programming languages such as "C" and "C++" compile Source code into Machine code suitable for execution on a particular environment/architecture or operating systems such as Windows or Unix. This property does not make these language architecture neutral and does not follow the concept of "Write here, Run anywhere."

Virtual means that does not physically exist but is created within another environment. Usually Java Virtual Machine is a platform-independent-execution. The phrase “Java Virtual Machine” is commonly used to describe Java runtime environment.

Java Virtual Machine contain following fields that are:

  • 1. Classloader
    • a. Read class file stream.
    • b. Test/Affirm the class file.
    • c. Conclude the class link.
    • d. Load into memory.
  • 2. Interpreter
    • a. Execute Java bytecode
  • 3. Garbage Collector
    • a. Delete unused Java objects automatically.

Java virtual Machine is used for mainly following purposes:

  • 1. Small size of compiled code
  • 2. Protecting users from malicious programs
  • 3. JVM does not know about Java, It only understood the class file.
  • 4. JVM contain following things to access in runtime:
    • i. Method Area //Runtime shared storage area
    • ii. Native Method Stack //To serialization of byte code in method
    • iii. Heap //Garbage collector

Java Source Code is both compiled and interpreted.

Just In Time (JIT) compiler is the part of Java Virtual Machine.

The following figure can easily define the working process of JVM.


Figure: Compilation Process of Source Code


Figure: Process of converting Byte code into Machine code

Combined Figure