1.6 JVM Implementations

One of the design goals of the virtual machine is that it can be emulated by a program on a real machine. This enables almost any actual computer to serve as a Java virtual machine by using a JVM emulator. A JVM implementation is a program for your system. Unlike Java virtual machine programs, which will run on any implementation, the JVM implementation depends on the specifics of your system.

Many different JVM implementations are available for a variety of platforms. One of the most popular is the Java Development Kit (JDK), from Sun Microsystems, which runs on both Solaris and Windows platforms (both NT and 95/98), covering over 90% of the computers in the world. It's free and available from http://java.sun.com. Because it comes from Sun, the inventor of Java, the JDK virtual machine is the standard against which all other implementations are measured. The full package contains a debugger, a Java compiler, and documentation, as well as an implementation of the Java virtual machine.

In the JDK, the JVM implementation is a program called java. It takes as an argument the name of the class to execute; the subsequent parameters become arguments to the JVM program. For example,

 java Hello 

finds a class named Hello and executes it. It begins in a method called main, which takes an array of strings as its argument. These strings are initialized to the rest of the words on the command line.

Other JVM implementations are available. Popular ones are made by Microsoft, Symantec, and Asymetrix. Most popular operating systems, including Solaris, Windows, and Macintosh, already incorporate JVM implementations. Kaffe is a free JVM implementation, available at www.kaffe.org.

Another common place to find Java virtual machines is as a part of a web browser. Both Netscape Navigator and Microsoft's Internet Explorer contain a Java virtual machine. It is accessed by loading an HTML page containing the APPLET tag, like this:

 <APPLET CODE="HelloApplet.class" WIDTH=100 HEIGHT=200> 

The CODE parameter names a file in the class file format. The browser's virtual machine interprets that class file, creates an instance of the class found inside, and calls its init method.

Yet another place to find Java virtual machines is as part of the system itself. Embedded systems, supporting the EmbeddedJava platform and the Java virtual machine, are becoming more common. These systems sometimes use existing processors, or Sun's picoJava processor, which runs JVM bytecodes as its native machine language. Embedded JVM systems include smart cards, which incorporate a JVM into a device as small as a credit card.



Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net