Thursday, November 20, 2008

Does JAVA need Java Virtual Machine (JVM) to run?

Java can be embedded into web apps

The platform independence of Java comes through the process of execution as conceived by its designers. Essentially when a java file is compiled, a class file is generated. The class file is of a fixed standard structure that is the same regardless of the platform where it has been compiled. This compiled class file contains machine- independent instructions that define ‘what’ has to be done. All that is needed is software that interprets the class file format and executes the instructions. This software could be a part of any application or it could be a standalone program like the ‘java’ interpreter.

Importance to Internet

The fact that the class file interpreter can be a part of any software enables Web Browser developers to integrate this feature as a part of browsers. The browser reads the HTML document and downloads any files that are embedded and can be handled by it. A class file that is embedded into an HTML is known as an Applet. After downloading the applet, the browser executes the class file in a manner similar to any other Java interpreter. Since the class files have been designed to be platform- independent, the execution of an applet is possible on any platform provided a Java-Enabled Web Browser is available on that platform.

This gives flexibility and power to web designers so that they can not only deliver formatted material with lively content but also include algorithimic capabilities. All these go a long way toward making user interactions more simple and natural.

What is the Java Virtual Machine ?

Any environment that can execute a Java class file can be called a Java Virtual Machine. By definition a software that adheres to the specifications laid down by Java would be able to execute any Java class file that has been compiled from any Java compiler that again is at par to Java specifications. This feature of a JVM makes it an agent which enables portability of Java on the platform in consideration.

Sun has defined a set of rules that a JVM should comply with. The JVM need not understand how Java syntax and algorithms are handled. All that is needed is to implement all the Java assembly instructions defined by the JVM specifications. Any Java file when compiled with a standard Java compiler will generate a class file that corresponds to the JVM standards.

0 comments :

Post a Comment