LiveConnect (Product)

A Netscape Communications technology that provides a means of communicating between plugins and Java applets.

In Netscape, communication between scripts and Java applets takes place via the LiveConnect interface. LiveConnect was originally designed for just this purpose. LiveConnect is only implemented in Netscape. However, similar but not identical functionality is available in MSIE via the ActiveX interface.

LiveConnect is most effective if you can also understand the internals of Java applets and can program in Java yourself. You can use LiveConnect to gain read and write access to the public fields of an applet and you can also invoke public methods. You can also interact with standard Java system classes that are built into the Netscape browser.

If a plugin is Java-enabled, then in Netscape you can interact with that plugin in the same way.

From the opposite direction, applets and Java-enabled plugins can invoke JavaScript functions and can read and write JavaScript object properties. The Real Video plugin uses this to great effect as do many other media plugins.

LiveConnect is constructed around some built-in objects that encapsulate various Java classes and objects. These are:

With these encapsulations, you can operate on Java objects as if they were JavaScript objects. That is necessary because although you can generally convert between primitive types, the object types are too dissimilar to convert properly.

There are some interesting opportunities here for extending the capabilities of your scripts with the facilities offered by Java. However, the downside is that you need to have a VM running. Netscape supports its own internal VM at least up to version 4, but the trend is for browsers to use the OS hosted VM and to not provide any embedded Java execution context. This may provide additional benefits such as sharing Java classes amongst several applications and shortening the start-up time since the VM could be expected to be running already.

LiveConnect becomes particularly useful when accessing the java.lang.System class from scripts running in Netscape. In MSIE, you could create a special applet that then gained access to the system class for you. Using this capability to any useful extent starts to impinge on the security model and requires that trusted scripts are used. This is usually enough to deter most people from exploring it more deeply. However, if you can gain that trust, by using signed scripts, you may then be able to access the Java IO facilities and read/write files.

Working the other way, LiveConnect provides a way for Java code to execute a string as JavaScript. This is very like an eval() call from the native JavaScript environment.


See also:ActiveX, Glue code, Java calling JavaScript, Java method calls, Java method data conversion, Java to JavaScript values, JavaScript to Java values, LiveScript, Plugin events, Plugin.isActive()