Previous |
Next |
Because of inter company politics, Microsoft does not ship a copy of the Java plugin with its Internet Explorer web browser, and your users may find the idea of downloading and installing such a piece of software intimidating. Fortunately Sun has created a system whereby a user without the plugin will be offered the chance to download, install and run the plugin, fairly automatically. The users still face the delay of downloading a 5MB file the first time they try to access an applet, but this is a one off problem, and with many users having improved bandwidth, this should not be an insurmountable problem. Also you may modify the code to access a copy of the plugin on your local network to reduce the download time still further. The Java plugin is installed as an option when you install the Java Development Kit, so as a student on this course you should have it installed by default.
To check for the presence of the plugin and to re-direct the users you can process your html using a tool from the JDK called htmlconverter. This is a small graphical tool that allows you to select the directory and file types you wish to convert, and it then modifies your HTML to include the code needed to re-direct users who do not have the plugin installed.
You can find out more about the htmlconverter from
If the you want to deploy Java code that needs greater access than the security of Applets, another distribution system is Java WebStart. WebStart is like a web server based installation system that gives the benefit of making it easy to update applications. WebStart uses the standard HTTP protocol, so it should not have problems with FireWalls. If the application does require greater access than an Applet you will be asked if you are happy to give this permission. This means that you need to be confident of the source of the program before you install it. Java WebStart has been installed by default since J2SE1.4.1so the chances are that you have it installed already.
Java WebStart brings with it the advantage that after initial installation the programs will run from a local copy avoiding the performance overhead of the download that an applet involves. However each time the program launches there is an automatic check to where it came from to see if a later version of the program is available and the user is offered the chance to update to the latest version. With these features you get the ease of distribution of an applet with the performance of a locally loaded application.
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/html_converter_more.html
You can find out more about Webstart from sun at
http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/faq.html
And you can see an interesting tool for creating UML diagrams that can be installed via WebStart at
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jarGuide.html
Most significant Applets will consist of more than one class file. The problem with loading multiple class file through a web browser is that the HTTP protocol means the browser has to "negotiate" the process of starting and closing a connection for every individual file. This can add a significant overhead if there are multiple files. Thus it can take a disproportional time to load an applet, by contrast with how long it would take to load a single class file amounting to the same file size. There is a solution to this problem in that Java class files can be “wrapped up” in a single Jar file that contains the multiple class files required for the entire applet. The following is a quote from the documentation for the jar utility.
Jar files are also used by Java WebStart and when the correct association is made Jar files can act in a similar way to executables.
“When the components of an applet or application (.class files, images and sounds) are combined into a single archive, they can be downloaded by a Java agent (like a browser) in a single HTTP transaction, rather than require a new connection for each piece. This dramatically improves download time. The jar tool also compresses files, which further improves download time”.
The command line syntax of the jar program can seem somewhat arcane, however if you have a background in Unix/Linux the syntax is similar to that of the tar archiving program. If you are a mere mortal you might like to become familiar with the two following command lines.
jar -cvf MyJar.jar MyClass.class
jar -xvf jarfile.jar
If it helps as a memory jerker you can consider the command lines to mean
-create -verbose -file
and
-xtract -verbose -file
of course if you are a mere mortal it may seem entirely spurious to have to specify that you want to create to a file or extract from a file, but this syntax was "inspired" by UNIX where there is no such thing as too much detail.
Previous |
Next |