Java Overview
Java Improvements for Internet Explorer 4
How Java Works
Microsoft Virtual Machine for Java
Just In Time Compiler J/Direct
Java Security
Using Java Applets in Web Pages
Java is a programming language developed by Sun Microsystems and is a popular language for developing cross-platform-compatible Internet applications.
Internet Explorer 4 includes the Microsoft virtual machine for Java. It supports all functions of the Java Development Kit (JDK) Version 1.1, except for the following:
| • | Java Native Interface (JNI). Sun's proposed interface for linking Java code to platform-specific code. |
| • | Remote Method Invocation (RMI). Sun's technology to allow Java objects to communicate over a network. |
| • | Digital signatures in Java Archive (.jar) files. Sun's proprietary certificate format for digitally signing Java packages. |
In Internet Explorer 4, Microsoft provides a native code interface called Raw Native Interface (RNI) as well as support for the component object model (COM) and the new J/Direct technology for native code access. COM and J/Direct make integration with native code significantly easier than either JNI or RNI. Overall, JNI is slower than RNI and requires more development work than J/Direct.
Developers looking for a robust, secure, high-performance solution for remote object interoperability should consider Distributed COM (DCOM), which is supported by Java today with the Microsoft virtual machine and allows both Java-to-Java communications and Java-to-non-Java communications.
Internet Explorer 4 does not support signed .jar files, because they are a Sun proprietary technology. However, Internet Explorer does support unsigned and compressed .jar files. Internet Explorer also supports .cab files, which offer significantly better compression than .jar files. Internet Explorer 4 allows the signing of Java .cab packages with industry-standard x.509v3 certificates. For more information, see "Signing Code with Microsoft Authenticode Technology" in the Microsoft Internet Client SDK.
Internet Explorer 4 makes it easier for developers to create more full-featured Java applications for the Web. Java performance has been improved, making Java applications run even faster than in Internet Explorer 3. In addition, the Java security model has been greatly expanded and improved.
The following sections describe significant Java improvements available for Internet Explorer 4. For more information, see the Microsoft Internet Client SDK and the Microsoft SDK for Java 2.0, and visit The Microsoft Java Technologies Web page at http://www.microsoft.com/mscorp/java/ , the Microsoft Developer Network at http://www.microsoft.com/msdn/ , and the SBN programming workshop at http://msdn.microsoft.com/workshop/ .
For information about troubleshooting for Internet Explorer and for Frequently Asked Questions (FAQs) about .cab files in Java, see Appendix G and H, respectively.
The Java improvements for Internet Explorer 4 include:
| • | Speed. The Internet Explorer 4 Just In Time (JIT) compiler provides the fastest way to run Java applications. | ||||||||||
| • | Full component integration. ActiveX controls can be accessed as Java Beans, and Java Beans accessed as ActiveX controls. (Java Beans is a specification for the creation of components referred to as "beans" in Java.) The Microsoft virtual machine for Java is the only virtual machine that has this automatic, seamless, bidirectional component support. In addition, debugging is seamless between VBScript, JScript, and Java. | ||||||||||
| • | New object model. The Document Object Model is exposed through Java libraries. This allows Java developers to dynamically manipulate Web pages. | ||||||||||
| • | Improved Abstract Windows Toolkit (AWT). The AWT has been improved to reduce overhead and improve performance. New application foundation classes (AFC). AFC provides the easiest way for Java developers to build rich, commercial-quality applications quickly. They are written entirely in Java and are intended to be compatible with all high-quality implementations of Java. The advantages of AFC include:
| ||||||||||
| • | New multimedia class libraries. All the functionality of DirectX media and the DirectX foundation is provided as cross-platform Java class libraries, enabling developers to manipulate and animate a full set of media types. | ||||||||||
| • | Internationalization support. Unicode support simplifies developing worldwide applications, because it supports multilingual display and input, and its easy resource format facilitates localization. | ||||||||||
| • | New Package Manager. The Package Manager is a component of Internet Explorer 4 that manages the storage of Java class libraries. A database is used to associate properties and data with packages. When a component (the VM, development tool, and so on) wants to get class information, it calls a package manager API to get the information, instead of having to understand the complicated class path rules. The Package Manager works with .cab or .jar files to support the efficient download and storage of multiple .class files. | ||||||||||
| • | Complete Win32® integration. With Internet Explorer 4, Java developers can leverage the power of the Win32 platform by utilizing the rich Win32 API set natively from their Java code. | ||||||||||
| • | Trust-based security for Java. Internet Explorer 4 includes trust-based security for Java, which is a cross-platform security model for Java that provides fine-grained management of the permissions granted to Java applets and libraries. |
Java is unlike other programming languages in that a program can be written without consideration for the platform on which it will be run. A Java applet can run on a variety of dissimilar platforms.
Java requires a client-side interpreter or virtual machine (VM) for running Java code. Platform-specific considerations are built into the virtual machine, thus allowing the Java applications to be platform independent.
Java uses classes to call functions that exist on the system in the form of Java class libraries. These libraries are installed when Internet Explorer is installed. System classes are always required to run Java applets. Without system classes, no Java applet could run on a system.
The Package Manager loads classes using the following registry key:
HLM\Software\Microsoft\Code_Store_Database\Java_Packages\
The class libraries are stored in the C:\Windows\Java\directory.
Because Java was developed by the UNIX industry, applets use case-sensitive syntax and long file name extensions such as .class (the 8.3 equivalent of .class is .cla).
Basically, you write Java code, perhaps using Microsoft Visual J++ development software, and then save the noncompiled Java source code as a file with a .java or .jav file name extension. You then compile the source code to byte code, and the file is renamed with a .class (.cla) file name extension. The end users' Java VM compiles the byte code .class (.cla) files into machine-specific code, so applets can run on the end users' computers.
The Microsoft VM for Java provided in Internet Explorer 4 is the Win32 Reference Implementation of Sun's Java VM. Microsoft's implementation of the VM provides a number of benefits, including:
| • | High-performance native code interface |
| • | Separation of name spaces |
| • | Integration between Java and COM |
| • | Efficient, controllable garbage collection (GC) |
| • | Efficient internal object model, allowing better performance (in the VM, GC, JIT, and so on) |
The Microsoft VM for Java includes the following innovations:
| • | Integrated debugging and the industry's fastest Just In Time compiler for the fastest run-time performance of Java applets. |
| • | Cab file compression using Microsoft's new, cross-platform, open, backward-compatible Cabinet (.cab) packaging technology, which allows Java applets to download faster than ever before and allows users to install class libraries locally, avoiding repeated downloads across the Internet. |
| • | COM integration, which allows Java applets to communicate with the universe of existing software based on the industry-standard COM, including ActiveX, Automation, and Object Linking and Embedding. |
| • | Unicode support for development of international applications. |
The Microsoft VM for Java includes a new JIT that speeds up the Java compiling process, so Java applets run much faster in Internet Explorer 4 than in version 3. The JIT compiles the Java byte code to native code (platform-specific) during run time and ensures maximum speed and efficiency.
You can turn the JIT off by accessing the Advanced tab in the Internet Options dialog box in Internet Explorer 4. You can also use the Advanced tab to turn Java logging on, to record Java activity.
1. | On the View menu, click Internet Options. | ||||||
2. | Click the Advanced tab. | ||||||
3. | Configure the Java VM options you want.
|
A new feature of the Microsoft VM for Java, called J/Direct, allows Java code running on the Microsoft VM for Java to directly call Win32 functions. All you need to know is how to make the call in the C programming language.
The new Java packages and classes, such as AFCs and multimedia classes, that Microsoft provides in the Microsoft SDK for Java 2.0 are one way to access the Win32 API. These new Java classes let you use Windows functionality from Java without writing any C code, but they do not cover all aspects of the Win32 API.
J/Direct, by providing a way to call functions exported from any Windows DLL, addresses the need of Java developers to access the full Win32 API directly from their Java code.
Using the Win32 API directly from Java, however, can cause sticky problems. Windows was written to be accessed from C, and because of the many fundamental differences between C and Java data types, it's tricky to build parameter lists and receive return values. There are compatibility problems: Java does not have pointers or a representation for unsigned numbers; Java strings don't look like C strings; and Java doesn't have an analog for the C structure data type. In addition, there are problems in calling conventions — such as how to invoke Win32 functions that use callbacks, or who allocates memory buffers. To help with these problems, J/Direct provides a set of guidelines and helper classes that outline the best ways to interact with the Win32 API from Java code.
If you need to access functionality provided by an existing Windows DLL, and you already know how to use that DLL, J/Direct lets you get the job done. J/Direct enables Java code to call functions exported from any Windows DLL. The code in the DLL does not need to be aware of the Java environment. You can use J/Direct to call Win32 APIs or APIs in third-party DLLs. J/Direct can speed up Java applications on Win32 platforms.
Internet Explorer 4 introduces a new Java security model called trust-based Java security. The original Java security model limited Java applets to running in a "sandbox" that prevented applets from accessing a computer or network resources, but that also greatly restricted what applets could do.
Trust-based security for Java is a cross-platform security model for Java that provides fine-grained management of the permissions granted to Java applets and libraries. It uses Java Cabinet (.cab) signing technology to ensure that an applet can only perform actions for which it specifically requests permissions. With trust-based security for Java, developers can precisely limit the section of code where permissions have been granted, and administrators can have flexible control over the permissions granted to local classes. When combined with Internet Explorer zones, trust-based security can also simplify security decisions for end users.
For more information about trust-based security, see Chapter 29, "Trust-Based Security for Java," and visit the Microsoft Security Advisor Web page at http://www.microsoft.com/security/ .
To use a Java applet in a Web page, you use the APPLET element as shown in the following example:
<APPLET CODE="loading class" CODEBASE="relative path to the file"> <PARAM NAME="parameter name" VALUE="value"> </APPLET>
Note If a Java applet is compressed as a .cab file, the OBJECT element can be used.
For more information about using Java applets in Web pages, see the Microsoft Internet Client SDK and the Microsoft SDK for Java 2.0.
![]()