Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Java Developer's Reference

Chapter 13 -- HotJava and Other Java-Enabled Browsers

Chapter 13

HotJava and Other Java-Enabled Browsers


CONTENTS


For users and developers new to the Java world, the great amount of new terminology tends to be a little confusing. Questions often asked are



The answer to the first question can be found by reading Chapters 7 and 8, "Developing Java Applets" and "Developing Java Applications." This chapter will focus on the second question-Web browsers that support Java applets. By demonstrating the capabilities of these Web browsers, the differences between Java, JavaScript, and HotJava should become apparent.

Currently, three Web browsers support Java applets: Sun HotJava, Netscape Navigator 2.0 (or greater), and Microsoft Internet Explorer 3.0. This chapter will explore these three products and illustrate differences between them. The first browser to be examined will be Sun's HotJava.

The HotJava 1.0 Browser

The HotJava Browser is a product of Sun Microsystems' JavaSoft. It is the only Web browser that not only supports Java applets but also is actually written in Java. Although the browser market is dominated at the present time by Netscape's Navigator and Microsoft's Internet Explorer, the HotJava 1.0 release will run as a platform-independent application. This means that if devices such as Oracle's Network Computer become widely used, HotJava will undoubtedly be the first browser available for these platforms. Because the beta versions of HotJava were written using a special version of the JDK, however, pre-1.0 releases are platform-dependent.

What is now known as the HotJava product actually was introduced as a stand-alone Web browser back in the spring of 1995. As Java's potential was recognized by the public and its popularity skyrocketed, HotJava came to be much more than a Web browser. The HotJava product now refers to a set of Java class libraries that simplifies the creation of Internet-aware applications. The HotJava browser is provided as a showcase of these class libraries' capabilities. The HotJava class library will be available from JavaSoft as a licensable product at a later date. At this time, HotJava can best be explored by downloading and installing the HotJava Web browser.

Installing the HotJava Browser



Like the JDK, HotJava can be downloaded for free by visiting the following location:

http://www.javasoft.com/java.sun.com/HotJava.

Note
Unlike the JDK, HotJava does not currently support the Apple Macintosh operating system. However, Sun Solaris and Microsoft Windows 95/NT are supported. Apple Macintosh support is planned to coincide with the release of the JDK V1.1.

These installation instructions will be split into separate listings for Solaris and Windows. To install HotJava, follow the instructions that apply to your platform.

Sun Solaris 2.4+ SPARC-Based Machines

The HotJava browser can be obtained by FTP at ftp://ftp.javasoft.com/pub/. At the time this book was written, the current version of the browser was the pre-Beta1 release. The filename to download is hotjava-1_0prebeta1-solaris2-sparc.tar.Z. (To retrieve the latest version, visit the HotJava home page at http://www.javasoft.com/java.sun.com/HotJava.)

This file is in the TAR format, so once it has been downloaded, you need to "untar" the file. Use the following command to untar the file:

% zcat hotjava-1_0prebeta1-solaris2-sparc.tar.Z | tar xf -

This will create a /HotJava directory in the directory where the file was unzipped. This directory should contain all of the HotJava files including the classes.zip file that contains the HotJava class library (more on this later).

Caution
As with the JDK's classes.zip file, do not unzip the HotJava classes.zip file.

If you previously have installed Alpha or earlier Beta versions of HotJava, you may need to unset the environment variables HOTJAVA_HOME, JAVA_HOME, or CLASSPATH. You can do this by executing the following command:

% unsetenv JAVA_HOME HOTJAVA_HOME CLASSPATH

Microsoft Windows 95/NT

The HotJava browser can be obtained by FTP at ftp://ftp.javasoft.com/pub/. At the time this book was written, the current version of the browser was the pre-Beta1 release. The filename to download is hotjava-1_0prebeta1-win32-x86.exe. (To retrieve the latest version, visit the HotJava home page at http://www.javasoft.com/java.sun.com/HotJava.)

This file is in a self-extracting zip format, so once it has been downloaded, all you need to do is execute the file. This will create a \HotJava directory in the directory where the file was unzipped. This directory should contain all of the HotJava files including the classes.zip file that contains the HotJava class library (more on this later).

Caution
As with the JDK's classes.zip file, do not unzip the HotJava classes.zip file.

If you previously have installed Alpha or earlier Beta versions of HotJava, you may need to unset the environment variables HOTJAVA_HOME, JAVA_HOME, or CLASSPATH. You can do this by removing these lines from the AUTOEXEC.BAT file (under Windows 95) or by making these changes using Control Panel's System tool (under Windows NT).

Installation Tips

If you followed the preceding steps, the HotJava browser should be ready to run. Test the installation by running the HOTJAVA.EXE application. If the browser returns an error or is unable to run, read on for a list of potential problems:

  1. Under Windows 95, the HotJava browser requires the Microsoft Windows 95 TCP/IP drivers. If your system is using anything but these drivers, HotJava will be unable to run.
  2. HotJava will not run under Windows 3.1. Do not confuse Windows 3.1 with Windows 95/NT because they are actually very different platforms.
  3. Don't forget to delete the downloaded file after its contents have been extracted. This will free up file system space.
  4. If you were unable to extract the downloaded files, make sure that they were downloaded using binary format, not ASCII.

HotJava Features

The HotJava Web browser supports many of the most popular browser features. Most importantly, of course, it fully supports the running of Java applets (see Chapter 7 for more information on applets). It also has the following features, some of which are unique to HotJava:

Using HotJava

HotJava can be run by executing the HOTJAVA application located in your installation's bin directory. Figure 13.1 shows the HotJava browser loaded and running under Windows 95.

Figure 13.1 : The HotJava Browser running in Windows 95.

The browser will initially load a page that was included in the HotJava installation (in this case ./lib/hotjava/whats-hot.html). To enter another address, simply click on the current document's title. When this is done, a URL text entry box will be displayed. HotJava supports the following Internet transfer protocols:

Navigating in HotJava

Figure 13.2 shows the navigation buttons available to the HotJava user.

Figure 13.2 : The HotJava navigator buttons.

These buttons are used, from left to right, to

The last button bears some special mention because this feature is unique to the HotJava Web browser. HotJava features a sophisticated HTML parser that can detect errors in HTML pages. The last button on the HotJava toolbar is used to display any HTML errors located within a page.

The File Menu

The File menu contains the usual suspects: Open, Save, Print, Send, Close, and Quit. The following list explains the File menu options in more detail:

Clone Window  Opens a new HotJava window displaying the page that is currently loaded in HotJava. (This feature seems to be a little buggy in the pre-Beta1 release of HotJava.)
Open Page  The equivalent of clicking on the Document Name field to display a URL text field. This feature is useful if a mouse isn't handy.
Open Document  Displays a file open dialog, which allows the user to select a file on the local system.
Save  Saves the current page to an HTML file on the local system.
Print  Displays the print dialog for setting print options before printing the current document.
Send  Loads the Send Mail form. (Note that this form is actually maildoc.html. This means that this form, like most other forms within HotJava, can be completely customized by the HotJava user.)
Close  Iconizes the HotJava application according to the HotJava documentation; however, this feature in the pre-Beta1 release seems to serve the same function as the Quit option.
Quit  Shuts down the HotJava browser.

The Edit Menu

The Edit menu contains normal Edit options such as Cut, Copy, and Paste. In addition, it contains more detailed environment editing options as well. The following list explains each menu item briefly:

Undo, Cut, Copy, Paste, Clear  Currently disabled. These items will be operational by the release of version 1.0.
Find  Enables the Find text entry field. Any text entered into this field will be used to search the current document.
Use Index  Enables the Index text entry field. Any text entered into this field will be used to search the current document's server. This option is only enabled for documents containing the ISINDEX HTML tag.
Preferences  This menu item contains several submenus: Display, Proxies, Mail, and Applet Security.
Display  This option will load a form that contains several entry fields (see Figure 13.3). This form will allow the user to change default font sizes, set a home page, and control the display of the HotJava welcome screen.
Figure 13.3 : Contents of the Preferences Display form.
Proxies  The Proxies option will load a form in HotJava that allows the user to set HTTP, gopher, FTP, caching, and SOCKS proxy server for users accessing the Internet from within a firewall.
Mail  Loads the Mail Preferences form containing fields for entering a default e-mail address and the name of your SMTP Mail server. If you are unsure of the name of your mail server, check with your Internet Service Provider (ISP) or your system administrator.
Applet Security  This is the most interesting of these options. Although the security limitations of applets have been described in some detail throughout this book, those in fact were the default security limitations. HotJava actually allows you to disable (or weaken) security precautions and allow applets complete file access on your local machine, as well as the ability to communicate with other computers across the Internet (in addition to the server the applet was sent from). Unless you have good reason for not doing so, these security settings should be set to the following:
Network Access = Applet Host
Class Access = Restricted
If, for some reason, you would like to configure your HotJava browser to allow applets to read and write files on your local drive, you can do so by modifying the Access Control List in the HotJava properties file. This file is located in the ./.hotjava directory. Although the Access Control List is blank by default, it can be modified by adding the acl_read and acl_write properties, using the following syntax:
acl_read=[directory_name1 or file_name1]:[directory_nameN or file_nameN]
acl_write=[directory_name1 or file_name1]:[directory_nameN or file_nameN]

Note
These security settings are completely browser-dependent and not reliant in any way on Java or the Java Virtual Machine. Developers who complain that Java is too restrictive are generally misinformed (or underinformed). In general, it is the Java default implementations that are designed to be restrictive (for good reason!).

The View Menu

The View menu contains a set of options that apply specifically to the current page that is being viewed. The following list explains each menu item briefly:

Reload Page  This option is equivalent to hitting the Reload button (refer to Figure 13.2). It is used to reload a page when the current HTML page may have changed.
Stop Loading  Equivalent to hitting the Stop button (refer to Figure 13.2). This will stop the loading of all applets and pictures, but will not stop applets that have already begun running.
Flush Cache  This option will remove all files from the HotJava cache. If a page has recently been loaded in HotJava, it will have been stored in the cache for speedier access. However, if that page has changed on its Web server and you would like to load the most up-to-date version, the cache will need to be flushed.
HTML Source…  Allows the user to view the HTML source of the current HTML page.
HTML Errors…  Equivalent to selecting the HTML Errors button. Shows form detailing all HTML style or tag errors.
Show Tags  Shows all HTML tags on the current page. Useful for beginning HTML developers.
Monitor  The Monitor menu contains the following submenus: Progress, Memory, and Thread. These submenus load HTML pages that can be used to see the current state of various operations. Remember to hit the Shift key when selecting any of these options to load a separate HotJava window. Otherwise, these pages will replace the current HTML page you are viewing.
Monitor Progress  This submenu selection will load a form that shows the progress of the current form load process. Note that a miniature version of the progress bar is located in the right corner of the HotJava browser window. When the progress bar is completely filled, the loading process has been completed.
Monitor Memory  This selection will load a form that shows a bar graph illustrating the amount of total free memory and the amount that HotJava is currently using. At the bottom of this page is a button that will clean up memory previously allocated by HotJava.
Monitor Thread  This submenu selection will load a form showing all active threads in HotJava with their priorities and thread groups. Available options allow the user to Raise/Lower thread priorities as well as kill active threads (see Figure 13.4).

Figure 13.4 : The HotJava Monitor Thread page.

The Places Menu

The Places menu contains a set of operations that is used to navigate to different Web pages. A "place" in HotJava refers to a saved link to a chosen Web site. This is similar to the "Favorites" list in Netscape Navigator or Microsoft Internet Explorer. The following list explains each menu item briefly:

Back  The Back menu item is equivalent to the Back button (refer to Figure 13.2). It returns the main screen to the previous document loaded in HotJava.
Forward  The Forward menu item is equivalent to the Forward button (refer to Figure 13.2). It returns the main screen to the next document loaded in HotJava.
Home  The Home menu item is equivalent to the Home button (refer to Figure 13.2). It returns the main screen to the home page (also see the preceding section on the Edit/Preferences menu selection to find out how to set the default home page).
Add Current To Places Menu  Selecting this item will add the current page to the HotJava Places menu. This menu is used to retain a list of "favorite" locations that will be accessed often.
Show All Places  Displays a page showing the "Remembered" and "Places" lists together. The Remembered list can only be reached by this page and is used to store locations that won't be accessed often (unlike the Places list, which will appear on the bottom of the View menu). Options exist on this page to import and export lists from/to HTML and to move locations from the Remembered list to and from the Places list.
Show History  Shows a list of all locations visited during the current HotJava session.

Planned Features for HotJava 1.0

The following feature set is planned for the 1.0 release of HotJava:

The Netscape Navigator 2.0 Browser

If you are like the average user of the World Wide Web, the chances are extremely good that you currently use the Netscape Navigator Web browser. Surveys have shown that Netscape currently controls over 70 percent of the Web browser market. Currently, versions of this browser are available for Windows 3.1, Windows 95/NT, Apple Macintosh System 7, and Sun Solaris 2.3 or greater. Because Netscape has nearly all of the features included in the HotJava Web browser, we will not spend a great deal of time discussing each individual feature of the Navigator (or Microsoft's Internet Explorer, for that matter). Instead, particular attention will be applied to these browsers' support of Java, and in particular Java applets. Netscape supports a scripting language called JavaScript (which is not related to Sun's Java-more on this later).

Java versus JavaScript

The release of the Netscape Navigator 2.0 browser for Solaris and 32-bit Windows marked the first time a browser (outside of Sun's HotJava) supported the running of Java applets. Because of Netscape's astounding growth and the popularity of its browser, Java received a great boost in name recognition and availability on the desktop. Netscape uses a special version of the Java Virtual Machine to run Java applets within the browser. You can see this by visiting your Navigator installation directory (if you have installed Netscape Navigator). In the .\Program\java\classes directory, the file moz2_02.zip resides, containing the Java .class files used by Netscape. (Moz refers to Mozilla-a code name for the Navigator project at Netscape.) These class files resemble the classes included in the current release of the JDK, but some may have been modified by Netscape for specialized display, performance, and so on. What is important, however, is that Netscape had the vision to support Java in its infancy, and is now positioned, with its LiveConnect strategy, to provide developers with just about everything needed to build industrial-strength Web applications on the client side.

Both new and experienced developers are confused when forced to differentiate between Java, HotJava, and JavaScript. By now, the reader of this book should have a firm understanding of what Java and HotJava are. However, JavaScript may remain somewhat of a mystery.

JavaScript was initially introduced by Netscape as a feature known as LiveScript. It is fully incorporated into Netscape's Navigator 2.0 browser. JavaScript is a scripting language that is used primarily to build dynamic forms. Because Java applets generally do not interact with other elements on HTML pages, JavaScript can be used to tie the various elements together. Although much of the syntax is similar to Java, there are some major differences. Most notably, JavaScript does not allow the author to define new types of objects. Inheritance also is not allowed. JavaScript is not compiled. Instead, it is embedded within the <SCRIPT>…</SCRIPT> tag in an HTML form. See the Netscape home page (http://home.netscape.com) for more information on JavaScript.

Netscape and Java

The Netscape browser V2.0 includes complete support for Java applets on the Sun Solaris and Microsoft Windows 95/NT operating systems. A later version was released that added Java applet support for the Apple Macintosh. Currently, Java support has not been added for Windows 3.1 because the Java Virtual Machine has not been ported to that platform, although IBM apparently plans to do so in the near future.

The way Netscape handles applet security is what separates its Java support from the HotJava browser (besides sheer performance, which appears to be better in HotJava). HotJava allows the user to set security options, but Netscape does not. With Netscape, Java applets are not allowed to read or write to the local file system, and they are restricted to communicating only with the computer from which they came. In addition, unlike HotJava users, users of the Netscape browser can turn off applet support altogether. This was provided to pacify users who were initially concerned over reported Java security holes. See Figure 13.5 for Netscape's Java options.

Figure 13.5 : Netscape's Preferences dialog box.

The Netscape Navigator has one nice feature not found in many other Web browsers. That feature is the Java console (see Figure 13.6).

Figure 13.6 : The Java console in Netscape Navigator.

The Java console allows the user to see exactly what is being loaded in his or her display without having to examine the HTML source directly. This feature can come in handy when trying to debug Java and HTML forms.

Microsoft's Internet Explorer 3.0

Fortunately for Microsoft, "Web-mania" hit before the release of its Windows 95 operating system. This gave Microsoft developers the time to create their own Web browser, named Internet Explorer, and include it for free within their Windows 95 operating system installation. Unfortunately for Java aficionados, neither Internet Explorer 1.0 nor Internet Explorer 2.0 supported Java applets (nor JavaScript, but as we've seen, that's another topic entirely!). Internet Explorer 3.0 is promising Java applet support as well as support for a host of other semi-related technologies such as Visual Basic Script (VBScript), JavaScript, and Microsoft's ActiveX controls (see Figure 13.7 to view the Internet Explorer application).

Figure 13.7 : Microsoft's Internet Explorer 3.0.

Although the current beta of Internet Explorer 3.0 does not yet support Java applets, we assume that this support will be provided by the final release. What is more interesting with this product is the ActiveX technology and how it applies to Java programmers.

Java and ActiveX

For developers who thought that following the Java technologies alone was bewildering enough, ActiveX is sure to add an entirely new level of decision-making complexity. In a nutshell, Microsoft's ActiveX technology may be more familiar to developers when called by its old name: OLE (Object Linking and Embedding). OLE was renamed to ActiveX to more accurately represent the active, Internet-aware, distributed OLE that will soon be upon us. For Web developers, the most important ActiveX subset to understand may be ActiveX controls (formerly known as OCX controls). ActiveX controls are programming objects that encapsulate an object's properties, methods, and events. These controls currently are supported by nearly all popular Windows development tools including Visual Basic, Visual C++, Borland C++, Borland Delphi, Powersoft PowerBuilder, and many others. (ActiveX also is being ported to other platforms including the Apple Macintosh.)

What is new about the ActiveX control technology is that the Microsoft Internet Explorer 3.0 browser will allow these controls to be run within a Web page just as Java applets are. In fact, these controls could actually be running side by side with other Java applets. How is this done? Microsoft is developing a special Java Virtual Machine that will expose Java applets running within a browser as ActiveX controls. Any application using the Microsoft Java Virtual Machine will acquire this capability.

Microsoft envisions an environment where scripting languages such as VBScript and JavaScript will be used to tie all of these components together into dynamic, fully functional Web pages. Sounds great, right? Because Internet-aware ActiveX controls are so new, it remains to be seen whether developers will get excited and support them with the fervor currently directed toward Java. The remainder of this section will point out some differences between Java and ActiveX and leave it to the software market to sort out the better of the two.

Security

Because of the nature of the Internet, no large-scale development effort can be undertaken that does not take security into account at every level. The designers of Java and ActiveX have both provided security features in their technologies. However, they have arrived at very different results. As explained throughout this book, Java applets are treated as untrusted programs running within trusted environments (a restriction known as "sand boxing"). They can only be written using the Java language, which was designed from the ground up to be a secure language. ActiveX controls, on the other hand, are primarily created using C++, although Visual Basic 5.0 is rumored to provide support for ActiveX control creation. Whatever way they are created, obviously the languages used give programmers a way around Java's strict security limits. Microsoft is attempting to solve this problem through the use of secure digital signatures.

Because they recognize that the momentum behind Java is somewhat unavoidable, Microsoft plans to provide Java applets with the capability of calling remote ActiveX objects throughout the Internet, which violates Java applets' security rules. Microsoft realizes this and is promoting the concept of "code signing" to verify the authenticity and security of downloaded ActiveX controls and Java applets. Developers should realize that these extensions have advantages and disadvantages. In the meantime, Sun is encouraging developers to avoid all proprietary extensions to Java.

Note
Extending the base Java class libraries with new classes is not considered a proprietary extension. This is what object-oriented programming is all about! However, custom-izations of the Java Virtual Machine and Java .class file formats are considered proprietary extensions. Developers undertake these extensions at the risk of losing Java's platform independence and flexibility.

Platform Independence

At the time this book is being written, the Internet Explorer 3.0 (Windows-only) browser is the only application that will support the running of ActiveX controls within an HTML page. This means that any ActiveX controls you create will be restricted to a 32-bit Windows-only audience. In smaller corporate intranet settings where the audience is limited and known, this restriction may not be a limiting factor. However, if your product will be displayed on the Web to a wide audience, platform independence is a huge bonus.

Summary

Within a year of Java's introduction in 1995, it has seen unprecedented growth. The three Web browsers studied in this chapter all have the capability of running Java applets. It is interesting to note the difference in philosophies behind the creation of each of these three products. In the near future, the HotJava 1.0 product should be released with a complete class library of reusable Java components. This library will include components capable of displaying Web pages and will greatly ease the creation of "Internet-aware" applications. Also due for release is Netscape Navigator 3.0. This application will provide improved performance for Java applets (including a just-in-time compiler licensed from Borland). The release of the Microsoft Internet Explorer 3.0 will mark the availability of the first browser to support both Java and ActiveX.

Although this chapter provides a good introduction to Web browsers for Java programmers, it is recommended that you visit the Web sites for the respective companies for the latest and greatest information on their browsers. Here are the addresses:

http://www.javasoft.com/HotJava (Sun's HotJava)
http://home.netscape.com (Netscape Navigator)
http://www.microsoft.com/ie (Microsoft Internet Explorer)