Tuesday, 4 September 2012

13.Java Virtual Machine


A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems has stated that there are over 5.5 billion JVM-enabled devices.


A Java virtual machine is a program which executes certain other programs, namely those containing Java bytecode instructions. JVMs are most often implemented to run on an existing operating system, but can also be implemented to run directly on hardware. A JVM provides an environment in which Java bytecode can be executed, enabling such features as automated exception handling, which provides root-cause debugging information for every software error (exception), independent of the source code. A JVM is distributed along with a set of standard class libraries that implement the Java application programming interface (API). These libraries, bundled together with the JVM, form the Java Runtime Environment (JRE).
JVMs are available for many hardware and software platforms. The use of the same bytecode for all JVMs on all platforms allows Java to be described as a write once, run anywhere programming language, versus write once, compile anywhere, which describes cross-platform compiled languages. Thus, the JVM is a crucial component of the Java platform.
Java bytecode is an intermediate language which is typically compiled from Java, but it can also be compiled from other programming languages. For example, Ada source code can be compiled to Java bytecode and executed on a JVM.
Oracle, the owner of Java, produces a JVM, but JVMs using the Java trademark may be developed by other companies as long as they adhere to the JVM specification published by Oracle and to related contractual obligations.
The Oracle JVM, named HotSpot, is written in the C++ language.




If you start learning Java, 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.
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.

The above information is just very basic guide of what JVM consists of. Please refer "Inside JVM" book in order to learn more about JVM in detail.



Best Study Materials JAVA,
Java Tutorials PDF,
Java SCJP Questions,
Java Material Free Download,
Gate Study Material Free,
Java Tutorial Download,
SCJP Materials
Core Java Programming Questio…
SCJP Certification  

Er Ratnesh Porwal
Software Engineer
www.AeroSoftCorp.com
www.AeroSoft.in
www.AeroSoft.co.in
www.AeroSoftseo.com
On Line Assistence    :
Gtalk                          :   ratnesh.aerosoft@gmail.com
Y! Messenger                   :   ratnesh.AeroSoft@yahoo.com
Rediff Bol                  ratnesh.AeroSoft@rediffmail.com

No comments:

Post a Comment