Contents:
Overview of LiveConnect
LiveConnect Data Types
LiveConnect Data Conversion
JavaScript Conversion of JavaObjects
Scripting Java with JavaScript
Using JavaScript from Java
Working with Java in Internet Explorer
Summary
Navigator 3.0 opens up a tremendous new set of programming possibilities by allowing JavaScript to communicate with the Java virtual machine running in the browser. Netscape's name for this new JavaScript-to-Java and Java-to-JavaScript communication facility is "LiveConnect." This chapter explains how LiveConnect works, and how you can use it in your programs.
Note that Internet Explorer 3.0 does not support LiveConnect. Instead, it treats Java applets as ActiveX objects and allows them to be scripted through that mechanism. Doing so is described briefly at the end of this chapter.
To use LiveConnect, you'll need to understand Java programming. This chapter assumes you have at least a basic familiarity with Java (see Java in a Nutshell, by David Flanagan, and Exploring Java, by Patrick Niemeyer and Joshua Peck, both published by O'Reilly).
LiveConnect is the mechanism that allows JavaScript and Java to work together. Using LiveConnect, all of the following are possible:
The surprising thing about LiveConnect is how easy it makes it to accomplish these difficult things. LiveConnect automatically handles all the required communication and data type conversion that must take place to allow Java and JavaScript to work together. LiveConnect is an underlying communication framework that opens up all sorts of possibilities for communication among JavaScript programs, Java applets, and Java-enabled plug-ins. LiveConnect can be thought of as the glue that ties these things together. Figure 19-1 illustrates this.