Source code would be platform independent, but neither efficient nor compact;  machine code would be efficient but not platform independent.  So SUN defined a virtual machine, JVM.  Java source code is translated to JVM code, which is then downloaded along with web pages.  The web browser includes a JVM implementation, which either interprets the JVM or translates it into machine code on the fly (JIT:  just-in-time compiler).  Processor chips have also been developed which execute JVM code directly.
JVM is a stack machine;  this makes it simple to generate JVM code, and makes the JVM code compact.

0 comments :

Post a Comment