Bambookit Home    Bambookit GUI Tutorial

Next   

Chapter 21. Java Plugin, Auto download



The following section in the tutorial describes how automatically download a Java plugin if a Java VM was not present on the client machine.

The Bambookit GUI's applet is executed if there exists a Java 1.1+ compatible VM.
If not available then a compatible Java VM is loaded and installed with a single click
The VM that gets downloaded should be SMALL, should not ask where it should be installed, should not popup a download page, but to immediately begin downloading the plug-in


To accomplish this we would need to use the Object tag (a W3C recognized tag). There are a few compatibilty issues when dealing with earlier versions of Netscape which we will touch upon a bit later.

<Object></Object>
Although Object tag has several attributes we will only concern ourselves with CLASSID, CODEBASE, ID, WIDTH, HEIGHT

CLASSID

CLASSID is the only required attribute of the OBJECT tag. It contains a unique identification tag that is generated whenever the control is compiled. The aspects of versioning will also be addressed further down the document.

Since this is an Object tag, Windows treats any embedded control as an ActiveX control (even a Java plug-in). Thus the browser security settings placed on ActiveX controls will affect the Java plug-in.

How can you find the CLASSID of the control you wish to use. Either the ID is provided to you or you could manually locate them in the registry by using REGEDIT.exe to find it.

For users to access an ActiveX control on your web page, the control must be installed and registered on the user's computer.

The CLASSID for Sun's VM is:
CLASSID="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

The CLASSID for MS's VM is
CLASSID="clsid:08B0E5C0-4FCB-11CF-AAA5-00401C608500"

CODEBASE

So how do you ensure the user has the control installed before accessing your web page?
The CODEBASE attribute!
The codebase attribute is used to specify a relative or absolute URL from where the control should be downloaded.
When the web browser sees the tag >OBJECT< tag in your web page, it checks to see if the control is already installed user's computer by checking the user's system registry. If the control is installed then the this control is used on the Web page. If it is not installed then the web browser downloads the control from the URL specified in the CODEBASE attribute. Installs it and then uses this control on the web page. This control will then reside on the users computer, serving future requests without any additional downloads (based on matching CLASSID)

<OBJECT CLASSID="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" CODEBASE="/vm/jvm142.cab"> </OBJECT>

VERSIONING

There might be multiple versions of the VM on the database. If you wish to use a specific version of the VM then you would define the version number.

Versioning info is passed along in the CODEBASE attribute, the format is
CODEBASE="/vm/jvm142.cab#Version=N,N,N,N"

If you wish to ALWAYS download the cab file, you can set the values to
Version="-1,-1,-1,-1"

NOTE:
In the case of Bambookit GUI you should ALWAYS be using dynamic versioning. Meaning that if the user has an older version of the java plugin then the user will be prompted with a dialog to download the newer version (the CODEBASE must point to a cab file and not a web page).

To indicate a dynamic version of the Sun Java Plugin you should always use this CLASSID.
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
Thus the codebase version reference would mean at LEAST this version and above, if below this version then goto the URL reference (either a .cab or html file)

If the CLASSID starts with a
classid="clsid:CAFEEFAC-0014-0000-0000-ABCDEFFEDCBA"
Then that is a static reference, meaning that IF the exact version that is requested is NOT present than the browser will request the download. (i.e. if the Sun plug-in 1.4.1 is installed and the version is requesting that version 1.4.0 be installed and there is not a copy of that Java plugin on the client machine, then the browser will make the request to download that plugin.)

PARAM attributes

scriptable
A new addition for Java Plug-in 1.3 (and valid in 1.4.x) was the PARAM scriptable. This was added to improve performance of applets that do not require the use of JavaScript or VBScript. The value should be true if the applet requires scripting support and false if it does not. The value is false by default.

codebase
Specifies the base URL of the applet. The URL should be relative to the document URL. This PARAM element is required only if the applet is not located in the same directory as the document.

archive
Specifies the name of the Java archive.

mayscript
Specifies whether the applet is allowed to access netscape.javascript.JSObject. The value can be either true or false. Currently not used in Bambookit GUI 2.0.1 but be used in a later date.

Warning: If you use codebase in the applet tag to centralize the code then take note below:
<APPLET codebase = "a/b/c ...> <PARAM name="codebase" value="bamboo_b388.jar"> </APPLET> Then the direct mapping would be: <OBJECT ...> <PARAM name="java_codebase" value="a/b/c"> <PARAM name="codebase" value="bamboo_b388.jar"> </OBJECT>

Complete Script

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="200" height="200" codebase="http://java.sun.com/products/plugin/1.4/jinstall-14-win32.cab#Version=1,1,0,0"> <PARAM NAME="code" VALUE="Loader.class"> <PARAM NAME="codebase" VALUE="html/"> <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.1"> <PARAM NAME="loadGui" VALUE="main.xml"> <PARAM NAME="scriptable" VALUE="true"> <COMMENT> <EMBED type="application/x-java-applet;jpi-version=1.1" width="200" height="200" code="Loader.class" model="main.xml" pluginspage="http://java.sun.com/products/plugin/1.4/plugin-install.html"> <NOEMBED> No Java 2 SDK, Standard Edition v 1.4 support for APPLET!! </NOEMBED> </EMBED> </COMMENT> </OBJECT>

The Embed tag is required for the Netscape 4.x browser versions, for more info see the reference guide at the bottom of this page



Conclusion

Can this process be automated?

Yes, HTML Converter is provided free of charge by Sun MicroSystems.

How big will the download be?

The upcoming version of the Java Plugin 1.4.2 for Windows will be 1.3Meg download. At the times of this writing of this document it was still in beta and not available for download. (Be warned, for other systems, the plugin could be as high as 13Megs, Linux)

Detecting the Virtual Machine by Scripting?

Detecting the VM via scripts (JavaScript, VBScripts, JScript) alone is Hard.
No methods for determining the browser's Java Virtual Machine are supported in the W3C Document Object Model. There isn't any support in the Dynamic HTML DOM extensions for Internet Explorer or the DOM for the Netscape browsers. In a nutshell, that means there's no single cross-browser, script-only method to detecting the user's VM (Virtual Machine) from a Web page. See the references below "Sniffing for the Microsoft Virtual Machine" for a JavaScript reference

Can I download the Microsoft VM instead?

If you have the MS Java plugin control, MSJavX86.exe, this can be placed on your local intranet servers and referenced via the CODEBASE attribute of the OBJECT tag.
..codebase="http://myserver/MSJavX86.exe#Version=4,0,0,0"..

Can I use a Personal Java VM instead?

Currently we are unaware of any Personal Java Plugin available to download for free to use instead of the Java 1.4.2 Plugin. If any one has any information on such a plugin, please email us so we can add it to our pages at info@bambookit.com



References:
Sniffing the Microsoft Virtual Machine
Using Object Embed and Applet tags in Java Plug-in