Chapter 22. Using Java with JavaScript
As we discussed in Chapter 14,
Netscape 3 and
later and Internet Explorer 4 and later both allow JavaScript
programs to read and write the public fields and invoke the public
methods of Java applets embedded in HTML documents. Netscape supports
JavaScript interaction with Java applets through a technology known
as LiveConnect. Internet Explorer instead treats every Java
object (including applets) as an ActiveX control and uses its ActiveX
scripting technology to allow JavaScript programs to interact with
Java. Because Netscape's technology is specifically designed
for communication between JavaScript and Java, it has some features
that IE's ActiveX technology cannot provide. In practice,
however, the two technologies are fairly compatible. Although this
chapter is based on Netscape's LiveConnect, the key features it
describes work in IE as well.
This chapter begins with a discussion of how you can use JavaScript
to script Java applets, how your Java applets can invoke JavaScript
code, and how (in Netscape only) you can use JavaScript to work
directly with Java system classes. It then documents the nitty-gritty
details of how LiveConnect works. It assumes you have at least a
basic familiarity with Java programming (see Java in a
Nutshell, by David Flanagan, and Learning
Java, by Patrick Niemeyer and Jonathan Knudsen, both
published by O'Reilly).
|