HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

"Installing Java with the Browser"
Volume: 5 Issue: 3, p.30


Listing 1:

<?XML version="1.0"?>
<!DOCTYPE SOFTPKG SYSTEM "http://www.microsoft.com/standards/osd/osd.dtd">
<?XML::namespace href="http://www.microsoft.com/standards/osd/msicd.dtd" as="MSICD"?>

<SOFTPKG NAME="Sample Application" VERSION="1,0,0,0">
<!-- created by DUBuild version 5.00.3023 -->

    <TITLE>Sample Application</TITLE>


        <PACKAGE NAME="com.mysample.application" VER-



Listing 2:

//* Sample JavaScript installation script

// Make sure Java is enabled before doing anything else

if (navigator.javaEnabled()){

    answer = confirm("Do you want to install Sample Application?");

    if (answer){

      // Create a version object and a software update object

      vi = new netscape.softupdate.VersionInfo(1,0,0,0);
      su = new netscape.softupdate.SoftwareUpdate(this,"Sample

      // Start the install process
      err = su.StartInstall("java/download/Sample
Application",vi,netscape.softupdate.SoftwareUpdate.LIMITED_INS TALL);

      if (err == 0){
          // Find the Java Download directory on users computer
          JavaFolder = su.GetFolder("Java Download");

          // Install the JAR File. Unpack it and list where it goes
          err = su.AddSubcomponent("Sample

      if (err != 0){
           alert("Installation Aborted.");
           alert("Installation complete. You must restart Communica- 
    tor to use the Sample Application");

Listing 3:

package com.mysample.application;

import java.applet.Applet;
import java.awt.Graphics;
import java.lang.Runnable;
import java.util.Date;
import java.awt.Color;

* Sample.java
* @author Mike Jasnowski
* @version 1.0
public class Sample extends Applet implements Runnable{

      private String time_string;
      private Thread runner = null;

      public void init(){
             runner = new Thread(this);

      public void run(){
          while (true){
                time_string = new Date().toString();
                try {
                } catch(InterruptedException e){}

      public void paint(Graphics g){


Listing 4:


// Ensure Java is enabled

if ( navigator.javaEnabled() ) {  

   // Create a Trigger Object
   var trigger = netscape.softupdate.Trigger;    

   // Create a VersionInfo object
   version = new netscape.softupdate.VersionInfo(1,0,0,0);

   // Make sure SmartUpdate is available

   if ( trigger.UpdateEnabled() ){

        // Call ConditionalSoftwareUpdate pointing to Install JAR

        trigger.ConditionalSoftwareUpdate ("http://local  
           alert("Enable SmartUpdate before running this   
       alert("Enable Java before running this script.");



All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: info@sys-con.com

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.