Re: Applet files installable on client computer?
Posted By:
Laxman_Subramanian
Posted On:
Friday, April 19, 2002 09:25 AM
Yep !! you can do it ! .All you need to do would be is wrap the applet in a Jar , include a Javascript for installation of the applet in the Clients browser and digitally sign it .
Let me brief you the steps , I tried it once and it worked just fine . It was basically a signed and persitent Applet capable of reading and writing in clients machine.
The following is the procedure for Netscape Browser
Let me assume you have jar 'ed your class files
steps that follow would be to create a install script in java script
like this one
//Install.js// Make sure Java is enabled before doing anything else.
if ( navigator.javaEnabled() ) {
// Create a version object and a software update object
vi = new netscape.softupdate.VersionInfo(1, 0, 0, 0);
su = new netscape.softupdate.SoftwareUpdate(this, "MyApplet");
// Start the install process
err = su.StartInstall("java/download/MyApplet", vi,
netscape.softupdate.SoftwareUpdate.LIMITED_INSTALL);
if (err == 0) {
// Find the Java download directory on the user's machine
JavaFolder = su.GetFolder("Java Download");
// Install the JAR archive. Unpack it and list where it goes
err = su.AddSubcomponent("MyApplet", vi, "MyApplet.jar",
JavaFolder, "", this.force);
}
// Unless there was a problem, move JAR archive to final location
// and update the Client Version Registry
if (err != 0)
su.AbortInstall();
else {
su.FinalizeInstall();
alert("Restart your browser and return to this page.");
}
}
and then jar your AppletClassesjar file with your install script and then sign it
the steps for signing it would be like
SET ARGS=-d %CERT_DIR%
SET ARGS=%ARGS% -k %CERT%
SET ARGS=%ARGS% -Z %OUTER_JAR%
SET ARGS=%ARGS% -i %INSTALL_SCRIPT%
SET ARGS=%ARGS% %OUTER_DIR%
Signtool %ARGS%
and then in the HTML have it call the javascript
if (navigator.appName == "Netscape") {
ref = location.href.substring (0,
location.href.lastIndexOf("/") + 1)
trigger = netscape.softupdate.Trigger
version_no = new netscape.softupdate.VersionInfo(1,0,0,0)
if (version_no.compareTo(
trigger.GetVersionInfo("java/download/MyApplet")) > 0) {
location = ref + "MyAppletInstall.html"
}
}
This should work good for Netscape ..
Me forgot the IE part will post again . I remember reading a article in DDJ which was the basis on which I worked on this applet ..