The Java vision was to empower developers to “write once, run everywhere”. One way of achieving platform independence is to use middleware to mask differences. Enter the JVM; a stack-based virtual machine that uses 32-bit words, performs arithmetic using 2-complement and can execute compiled Java bytecode, typically .class or .jar files.
Registers are simulated by the java program; some of them are:
Program Counter: Points to the location of the next instruction to be executed.
Optop: Points to the top of the operand stack; identifying the currently executing method.
Frame: Points to the stack frame of the currently executing method.
Vars: Points to the local variables of the currently executing method.
This part is responsible for storing method arguments as well as local variables in any method. New method calls result in new stack frames being pushed on this stack. Once a method returns, its stack frames are popped off the stack. Stack frames have three sections: local variables, operand stack and frame data.
The Method Area
This is where the classes used by the currently executing method are stored. It tracks the current instruction and the program counter is set to the next instruction here too. Method area is also shared by all the threads of a process; for multi-threaded processes, monitors are used to ensure synchronization.
This is where objects are stored; (if you have ever had to increase heap size for programs with large memory requirements; then this is the place). Whenever you want to create a new object; memory is allocated from this storage.
Given that the JVM only translates bytecode into actions and operating system calls; this is insufficient to run java programs. Typically, the JVM is distributed with standard class libraries that allow you to make calls to the underlying system, do I/O and related stuff. The Java Runtime Environment (JRE) consists of the JVM and Java API classes; the Java API classes are needed to make system calls and also provide the necessary API interfaces to the JVM.
SoYouKnow: The original Sun JVM was written in C++ :); moreover you can write your own JVM provided you follow the standards specified by Oracle.
So thats it! Hope you liked it; if you do please share with your friends.