Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

define Java Virtual Machine

Most compilers translate from the source language (eg, C or Pascal) into machine language for one specific type of machine (eg, Pentium or Sun). The machine language for a Sun computer is not the same as for a Macintosh, or a Windows machine. You cannot use the same machine code program on different kinds of machines.

Most compilers produce code for a real machine

The Java compiler produces code for a virtual machine.

Java compilers translate applets in two steps. The first part of the translation is from Java source to Java Virtual Machine (JVM) machine code. This may seem strange because there isn't any real machine that can use JVM instructions yet!

JVM code is designed so that it is easy to translate it into machine instructions for real machines, so the second part of the translation to real machine instructions is done in the browser on the user's machine. The browser takes the applet JVM code that it gets from the server and translates from JVM code to the machine code the browser is using, eg, a Pentium. This compiler in the browser is often called a "JIT compiler". JIT stands for "Just In Time", and it means that the last part of the compilation is done just before running the program. The diagram below shows how the same applet JVM code is used by browsers on different machines.

Two step compilation allows Java applets to run on many kinds of machines.

No comments:

Post a Comment

Archives