As Java technology matures, Sun Microsystems (Java's creator) releases new versions of Java via the Java Development Kit (JDK). Netscape and other browser vendors support each new version by adding that version's runtime component -- the Java Runtime Environment (JRE) -- to the next iteration of their browsers. However, the lag time between Sun's introduction of a new Java version and the release of browsers that support it has frustrated corporate intranet developers who need to make use of the latest JRE's features (and bug fixes). And Microsoft's refusal to completely support the JRE in Internet Explorer 4.0 and 5.0 has made the situation even more frustrating for developers.
Sun has a solution to these problems. This solution bypasses the vendor and relies on plug-in technology to distribute newer JREs.
A plug-in architecture -- essentially the combination of an architecture and plug-ins -- is a specification for and implementation of that part of a browser that dynamically loads plug-ins as needed. Both Netscape and Microsoft have added this architecture to their browsers. (The actual implementations of the architecture are quite different: Netscape uses a simple executable implementation, while Microsoft uses its ActiveX object model implementation.)
A plug-in is executable code that is stored in a library file. When referenced via special HTML tags, the browser loads this library, via its plug-in architecture, and starts running the library's code. (If you've ever come across a Web page that references Macromedia's Shockwave or the VXtreme Web Theater, you've seen examples of plug-ins at work.)
Sun's solution is the creation of a plug-in for Java, known as Java Plug-in.
What is Java Plug-in?
Java Plug-in is a software product that serves as a bridge between a browser and an external JRE. A developer "tells" the browser to use this external JRE by placing special HTML tags on a Web page. Once this is done, a browser can run Java applets or JavaBeans components that have access to all the features (within the limits of Java's security model) of this external JRE.
Sun released Java Plug-in 1.1 in April '98. Shortly thereafter, JavaWorld polled its readership to gauge reaction to this product. The Java Plug-in 1.1.1 and 1.1.2 maintenance releases followed. (See Resources for details on the JavaWorld poll and releases of Java Plug-in.)
Concomitant with the release of JDK 1.2 (now known as the Java 2 platform), Sun has released Java Plug-in 1.2. However, unlike previous releases, this release is currently only available for the Microsoft Windows (95/98/NT) platform. Sun is currently working to make Java Plug-in 1.2 available for its Solaris platform.
This article explores Java Plug-in 1.2, starting with a discussion on how to download and install this technology. It is based on my experience using Java Plug-in 1.2 with the Internet Explorer 3.02 and Netscape Communicator 4.5 browsers, under the Windows 95 operating system.
Get plugged in!
Java Plug-in 1.2 is currently packaged with JRE 1.2. If you want to preinstall Java Plug-in, download and install JRE 1.2 from Sun's Web site, which is linked to in the Resources section. Or, you can choose to have your browser download Java Plug-in (with minimal intervention from you, depending on your browser) when you "surf" to a Web page that references that plug-in. Here's how:
When a browser comes across a Web page that requires the use of Java Plug-in, it checks to see if Java Plug-in has been installed on the same machine as the browser. If it hasn't, the browser must download and install the required files. The way this works depends on your browser, so we'll look at these differences next.
Netscape Communicator 4.5
If you're using Netscape Communicator, a Web page containing the HTML
<EMBED> tag that references Java Plug-in will activate the download. We'll explore
<EMBED> later in this article. For now, it's sufficient to know that
<EMBED> contains information telling the browser what plug-in is required and where to get it. Figure 1 shows the initial download page that is displayed when Communicator encounters a Web page that references a noninstalled plug-in.
If you click on the image on that page, Communicator displays a "Plug-in Not Loaded" dialog box like the one shown in Figure 2.
This dialog box shows us that the browser knows exactly what it needs (a plug-in for
application/x-java-applet;version=1.2) and where to get it (http://java.sun.com/products/plugin/1.2/plugin-install.html).
So what happens when you click the "Get the Plug-in" button? The browser switches from the current page to the page specified by the Internet address in the dialog box. From that page, you follow directions to download and install JRE 1.2 with Java Plug-in.
Once the JRE with Java Plug-in has been installed, on Netscape's next encounter with a Web page that requires Java Plug-in, this plug-in will be loaded from the local machine's hard drive and the applet or JavaBeans component will run, as shown in Figure 3.
Internet Explorer 3.02
If you're using Internet Explorer, a Web page containing the
<OBJECT> tag that references Java Plug-in will activate the process for downloading this plug-in. (As with
<EMBED>, we'll explore the
<OBJECT> tag later on in this article). This tag contains information that lets the browser know what kind of plug-in is required and where to get it. As we'll see, the process for getting Java Plug-in is somewhat more automated under Explorer than it is under Communicator. Figure 4 shows the initial page displayed when Explorer encounters a Web page that references a noninstalled plug-in.
(Note: The colorful diamond in the upper-left corner of the plug-in space appears if the computer is connected to the Internet. If the computer is not connected to the Internet, this diamond is replaced with a red X character, and obviously Explorer will do nothing to obtain the plug-in).
Assuming that the computer is connected to the Internet, Explorer proceeds to download a small ActiveX control that is responsible for downloading the Java Plug-in ActiveX control and JRE. Explorer displays the Verisign certificate associated with this first ActiveX control, as shown in Figure 5.
Assuming that you choose to install and run Java Plug-in, by clicking the Yes button in the previous dialog box, Explorer prompts you for locale information via the dialog box shown in Figure 6.
Once the locale information has been obtained (and you've clicked the Install button), Explorer displays a downloading dialog box, as shown in Figure 7.
Once the download is complete, Explorer will attempt to start the JRE with Java Plug-in install program. (The first time I downloaded Java Plug-in through Explorer, I received a CAB -- Windows cabinet -- file-corrupt error message, which prevented the install program from starting and completing the installation. The install program started and completed successfully on the second attempt.) As soon as the install program finishes, Explorer loads and runs the applet (or JavaBeans component), as shown in Figure 8.
Windows Registry settings
The JRE with Java Plug-in installation program records various JRE and Java Plug-in settings in the Windows Registry -- a centralized database of installation and other configuration data and a fundamental part of the various 32-bit Windows operating systems. The following table shows several Java Plug-in settings that are stored in this database. Each setting consists of a key that identifies a setting as well as the value of that setting.
The first two Java Plug-in settings are identified by the
RuntimeLib keys. The values associated with these keys are used by Communicator and Explorer to locate the JRE home directory and the JRE's runtime virtual machine, respectively. The directory information contained in these values reflects the default installation directory selected during installation. The remaining keys are used by the Java Plug-in Control Panel.
Command and control
The Java Plug-in Control Panel is a Swing application that makes it possible to modify the behavior of Java Plug-in. The JRE/Java Plug-in installation program adds an entry to the Windows program launcher that, when selected, activates the Java Plug-in Control Panel. This entry consists of the following line (assuming the default installation directory):
"c:\Program Files\JavaSoft\JRE\1.2\bin\javaw.exe" -classpath ..\lib\rt.jar; ..\lib\jaws.jar sun.plugin.panel.ControlPanel
The control panel consists of a tabbed interface with three tabs (Basic, Advanced, and Proxies) and two buttons (Apply and Reset). The Basic tab controls the basic operation of Java Plug-in. For example, you can choose whether or not Java Plug-in's own Java console will be displayed. The Advanced tab controls which JRE will be used with Java Plug-in along with debugging. The Proxies tab controls the addresses and port numbers that Java Plug-in uses when communicating, via an intermediate computer, with another computer over the Internet. The Apply button saves any changes made in the control panel, while the Reset button restores default values.
Figure 9 shows the control panel with the Basic tab as the active tab.
The Enable Java Plug-in checkbox, when checked, enables Java Plug-in to run applets or JavaBeans components. The default setting is enabled (the box is checked).
The Show Java Console checkbox makes it possible to display the new Java console while running applets or JavaBeans components. As we'll see later, the console displays messages that have been printed by
System.err objects (useful for debugging). The default setting is used to show the new Java console (the box is checked).
The Cache JARs in Memory checkbox, when checked, causes previously loaded applet or component classes to be cached and reused when that applet is reloaded, allowing for more efficient memory use. This option should be left unchecked if an applet or component is being debugged or if you want to make sure that the latest applet or component classes are being downloaded. The default setting is to cache JARs in memory (the box is checked).
The Network Access dropdown listbox allows you to choose which network access allowance you want to grant to your running applets and components. This option is enabled if you're running Java Plug-in 1.1.x. For Java Plug-in 1.2, you must use the new security architecture to enable the same behavior. (For more information, check out "Security and Signed Applets / Security Architecture" in the JDK 1.2 documentation.) By default, applets and components can only connect back to their original server (Network Access = Applet Host). When Network Access is enabled, you can use the following allowances, in addition to the default:
Disallow any network access so that an applet or component cannot make any network calls
- Allow unrestricted network access (which is a security hazard and must be used very carefully) so that an applet or component can connect to any host server
The Java Run Time Parameters text field overrides the Java Plug-in default startup parameters by specifying custom options. You would use the same syntax for this text field that you use when specifying parameters to the
java.exe command-line tool.
Figure 10 shows the control panel with the Advanced tab as the active tab.
The Java Run Time Environment dropdown listbox allows Java Plug-in to run with JDK 1.2 or any JRE that's installed on your machine. Java Plug-in 1.2 is delivered with a default JRE (currently JRE 1.2). However, you can override this default JRE and use an older or newer version. The control panel automatically detects all versions of the JDK or JRE that have been installed on the machine. It displays these versions within the listbox. The first item in the list will always be Java Plug-in Default, while the last item will always be Other. If you choose Other, you must specify the path to the JRE or JDK 1.2.
The Enable JIT Compiler checkbox (Win32 platforms only) enables the just-in-time (JIT) compiler. If you enable the compiler, you must also specify the path to the JIT compiler. The JIT compiler must be located in the
bin directory for the JRE or JDK that's been selected for the runtime environment.