The Java Virtual Machine Model
One interpretation of a virtual machine (VM) that is used frequently in the computer industry is the idea of the "simulated machine." This notion of the VM is very different from the IBM view of the VM. IBM’s idea was to partition the systems memory and resources into separate exact copies of the current machine. In the case of the simulated machine the system is not separated. A new "machine" or VM is instead placed on the current system, lending its distinct functionality to the user without altering the system. This type of VM has proven to be quite powerful allowing software developers to emulate one machine on a completely different machine. Recently this idea has brought about the creation of the powerful computer programming language, known as Java.
The Java programming language relies on the simulated machine, known as the Java virtual machine (JVM). The JVM allows the computer programmer to communicate with the virtual machine instead of the system. Thus the programmer utilizes functions that are built into the JVM and not the operating system. This is advantageous, because it allows for portability. If the same JVM is installed on two completely different machines then one Java program should work on both machines, because it relies on the JVM and not the system it is running on. Due to its relatively high portability, Java has become the principle programming language of the Internet. Many web pages now incorporate Java programs, which perform specialized tasks to be displayed on a browser.
Due to its relatively high portability, Java has become the principle programming language of the Internet.
The JVM is also very small. In other words, it does not use large amounts of memory. This means that the JVM can be placed into many different machines. Machines like TV sets, cellular phones, as well as computers. Thus, it is possible to add more complex functionality, like games, to many of the devices we use today.
How does it work?
What you might be wondering is how exactly a Java program works. How is the JVM used? Well, the JVM is what we call an abstract computer. In other words, it is implemented in software on top of a "real" hardware platform and operating system. Java programs are compiled for the JVM instead of the system. What that means is the programmer writes his/her Java program and the Java compiler translates that into language/codes that the JVM implements. These codes are called bytecodes. Bytecodes can be thought of as the machine language for the JVM. The JVM, interprets a stream of bytecodes as a sequence of instructions. These instructions are then executed to generate the desired output. Figure 1.1 shows the pathway a java program takes on its way towards execution.
As Figure 1.1 shows, once the bytecodes are interpreted by the JVM the instructions are mapped to instructions in the operating system or on the hardware. What this means is the JVM actually uses operating system and machine instructions to carry out the instructions it has been given. Thus the JVM must have a possible mapping for its instructions on every operating system or machine that it is installed on in order to work. This is one of the reasons why the Java programming language has not achieved 100% portability. It is possible that the JVM has instructions that one operating system is capable of carrying out, while another is not.
The main purpose of the Java Virtual Machine is to solve the problems with creating portable computer programs. The question is, does the JVM completely solve this problem. The answer is no...It does not completely solve this problem. However, it provides a good solution that is for the most part effective (although not 100 percent effective). Java has still achieved a relatively high degree of portability. The power of the Java has allowed people to develop many cross-platform applications and has proven to be a useful and powerful interpretation of a virtual machine.