Monday, June 8, 2009

JVM-Java Virtual Machine

JVM- Java Virtual Machine

At the heart of the Java platform lies the Java Virtual Machine, or JVM. Most programming languages compile source code directly into machine code, suitable for execution on a particular microprocessor architecture. The difference with Java is that it uses bytecode - a special type of machine code.

The designers of Java chose to use a combination of compilation and interpretation. Programs written in Java are compiled into machine language, but it is a machine language for a computer that doesn't really exist. This so-called "virtual" computer is known as the Java virtual machine. The machine language for the Java virtual machine is called Java bytecode. There is no reason why Java bytecode could not be used as the machine language of a real computer, rather than a virtual computer.

A program written in Java could certainly be compiled into the machine language of a real computer. And programs written in other languages could be compiled into Java bytecode. However, it is the combination of Java and Java bytecode that is platform-independent, secure, and network-compatible while allowing you to program in a modern high-level object-oriented language.

“Java is WORA Write Once Run Anywhere”

The Architecture of the Java Virtual Machine

The behavior of a virtual machine instance is described in terms of subsystems, memory areas, data types, and instructions. These components describe an abstract inner architecture for the abstract Java virtual machine.


Figure shows a block diagram of the Java virtual machine that includes the major subsystems and memory areas.


Figure The internal architecture of the Java virtual machine.

Each Java virtual machine has

ü a class loader subsystem: a mechanism for loading types (classes and interfaces) given fully qualified names.

ü Java virtual machine organizes the memory it needs to execute a program into several runtime data areas.

ü an execution engine: a mechanism responsible for executing the instructions contained in the methods of loaded classes.

Each instance of the Java virtual machine has one method area and one heap. These areas are shared by all threads running inside the virtual machine. As the program runs, the virtual machine places all objects the program instantiates onto the heap.

“Bytecode is independent , JVM is dependent.”

No comments:

Post a Comment