★ wanayoo — archive 1999 http://www.microsoft.com/java/resource/vm.htmNouvelle recherche | Portail wanayoo
Microsoft Technologies for Java   All Products  |   Support  |   Search  |   microsoft.com Home  
Microsoft
     Technologies for Java Home  |   Site Guide  |   Downloads  |   Technologies for Java Support  |

 Search Technologies for Java
 Advanced Search

 News and Information

 Technical Information

 Related Technologies

 SDK for Java








Legend

News and Information
Microsoft Virtual Machine Overview

Microsoft Corporation
April 1999

DownloadDownload this document in Microsoft Word format (zipped, 46 KB)

Technology Overview: The Microsoft Virtual Machine for Java

Java's "write once, run anywhere" promise is based on the fact that Java isn't just a programming language: it is also a run-time environment that relies on a virtual machine for its execution. The virtual machine is a "computer within a computer" that interprets and runs applets and applications-in theory, it guarantees a level of uniformity in the way Java is executed on almost any configuration of hardware and software. What that means, of course, is that the virtual machine is crucial in determining how well Java runs on a given machine.

The Microsoft® virtual machine (Microsoft VM) development team has built an award-winning virtual machine that offers extremely tight integration with the Microsoft® Internet Explorer browser, the Microsoft® Windows® platform, and a wide array of best-of-breed Java products and development tools.

Building a better virtual machine

A virtual machine works by taking incoming Java bytecodes and converting them to the native language of the machine the virtual machine is running on. Because the virtual machine is critical to how Java applications and applets are executed, Microsoft has devoted some of its best people to developing the Microsoft VM.

These efforts were rewarded when the Microsoft VM received the Editors' Choice Award from PC Magazine for the second year in a row. The award, which is based on both speed and robustness, found the Microsoft VM to be superior to all other virtual machines across the board. The JMark 2.0 benchmark tests developed by ZD Labs revealed that it ran over three times faster than any other virtual machine on the AWT graphics test, twice as fast on the Text test, and anywhere from 16 to 350 percent faster on the Processor test. The Microsoft VM also received the highest rating for robustness and compatibility, surpassing Sun environments by almost 20 percent.

"Although a number of . . . implementations show promise, nearly all were unable to deliver both good speed and high compatibility," wrote PC Magazine. "The Microsoft Java Virtual Machine for Windows was the exception, and it earns our Editors' Choice. For the second year in a row, Microsoft has produced the fastest and most reliable Java implementation available." In addition, notes PC Magazine, Microsoft "has also added a slew of proprietary features that are invaluable to Java developers committed to Java for Windows as a platform."

One Microsoft goal has been to allow developers to write applications in Java without sacrificing the power of the Windows platform. This has been achieved by tightly integrating Java and the Microsoft Component Object Model (COM), creating Microsoft® J/Direct™ application programming interface (API) to allow Java developers to call Windows functionality directly, and providing the Windows Foundation Classes (WFC) to simplify Java development.

Stay COM

With Java, developers can drop in chunks of previously written code-classes-when they create applets and applications. This code re-use helps makes software development in Java efficient. There are some limitations, however, with the way Java does this. For example, the Java classes used by a Java application must be present at compile time, when the code is written. An application composed of many classes may download slowly. And the downloaded classes must still be translated into the native language of the machine they are running on. In addition, and perhaps most importantly, developers who write entirely in Java are limited to classes that already exist in standard Java libraries, or classes that they write themselves.

The integration of Microsoft COM with Java allows developers to overcome these limits. While Java classes are required at compile time, COM classes are only required at run time. When creating an application, the COM developer writes code that manipulates COM objects retrieved from the operating system at the instant they are needed. Because the Microsoft VM supports calls to COM objects that are already present on the local machine in the machine's native language, Java applications using these COM objects download and run more quickly, with greater reliability.

COM also makes Java much more versatile. Overall, more than 150 million systems are COM-enabled. The Microsoft VM automatically converts Java objects to COM objects, and it makes any COM object accessible as a Java object. Instead of being limited to features provided in the standard Java packages, developers have access to the much wider range of COM-based features and functions included in the Windows operating system and the thousands of third-party products.

The Direct approach

Java/COM integration makes it possible to begin taking advantage of operating system-specific features. Microsoft J/Direct extends that ability considerably. The Microsoft® Win32® API is implemented in dynamic-link libraries (DLLs) containing executable routines. DLLs are loaded only when needed by a program. Although essential to Windows programming, DLL routines aren't normally accessible directly from Java. J/Direct provides a way to call functions exported from any Windows DLL, giving Java developers access to the full Win32 API directly from Java code.

Before J/Direct, developers had two choices: Java Native Interface (JNI) and Raw Native Interface (RNI). JNI, which was created by Sun, allows programmers to write wrapper DLLs around existing native code. But JNI is complex and inefficient. The Microsoft RNI is significantly faster than JNI, but it, too, is difficult to use. J/Direct was designed specifically to overcome these obstacles. Not only is it much simpler for developers to access native code with J/Direct, but applications written with J/Direct have the potential to run more efficiently by using less memory. However, for programmers looking for speed, RNI is the tool of choice. The investment in learning RNI pays off with performance.

This is a tremendous benefit for Java developers who need to create feature-rich, commercial-quality Java products that exploit all of the benefits and power of the Windows platform. With J/Direct, for example, developers can use Java to manipulate TrueType fonts and incorporate OLE interoperability features like drag and drop operations, even though Java doesn't support those features. J/Direct also provides access to third-party DLLs, giving developers access to a wide array of add-on libraries in their Java products.

A firm Foundation

Following the creation of J/Direct, Microsoft further enhanced the power and reach of Java with the introduction of the Microsoft Windows Foundation Classes (WFC). Shipped in September 1998, WFC is a new set of Java class libraries designed to provide a single programming model that unifies the Win32 platform and Web development. With WFC, developers can create full-featured Windows applications, take advantage of Dynamic HTML, and build server applications that generate HTML for delivery to any Web client. WFC can also be used to build powerful server components that are compatible with applications, and components that support COM on either the client or the server.

WFC accomplishes this through the creation of a component model that emphasizes a relatively small set of consistent, easy to understand rules about how components are created, how they interact, and how to extend, use, and reuse them. WFC includes a full set of classes for the Windows user interface, including elements like list boxes and toolbars. It offers access to Windows features that aren't otherwise available from Java, such as multiple documents in a single application. With WFC, developers can build applications without sacrificing the productivity they expect from traditional class libraries and tools. And because the Microsoft VM has been optimized for WFC, it automatically recognizes Windows Foundation Classes and executes them at speeds far beyond the norm for "pure" Java applications.

Tooling around

With each new release of the Microsoft award-winning VM, new features are added. Because speed is such an important issue, the Microsoft VM provides a set of Java profiling interfaces that help tool vendors and programmers analyze code for speed, memory use, and other factors that affect performance. The Microsoft VM supports run-time profiling, and can profile components that mix Java classes with COM objects and Win32 native code.

Debugging helps developers detect errors. The Microsoft VM debugging interfaces offer a powerful framework for locating errors in Java applications and applets. They can be used to debug Java code that mixes Java classes with COM objects and Win32 native code. These interfaces also support remote debugging.

Freedom of choice

In the real world Java developers are faced with the challenge of providing customers with robust, business-critical products that solve business issues. What matters here are results, and the fact that a majority of Java developers want to create applications and applets that call on native Windows code backs this up. The Microsoft implementation of Java provides exactly this tight integration with Windows.

If you are creating Java development tools to use with the Microsoft VM, here is a set of Link to Another Microsoft Site reference articles put together by the SDK for Java folks that you'll find quite useful.

 

Last updated April 29, 1999

© 1999 Microsoft Corporation. All rights reserved. Terms of use.