Full HTML for

Basic foilset Netscape's LiveConnect Technology

Given by Marek Podgorny,Nancy McCracken at CPS640 Internet and Multimedia Technologies on April 98. Foils prepared 2 October 98
Outside Index Summary of Material


This describes LiveConnect which is Client Side Integration Technology
We describe Java to JavaScript Connectivity and Vice Versa
We use wv plug-in as an example of linking plug-ins with Java and JavaScript
wv does wavelet decompression

Table of Contents for full HTML of Netscape's LiveConnect Technology

Denote Foils where Image Critical
Denote Foils where Image has important information
Denote Foils where HTML is sufficient

1 Linking Web Software Components with Netscape's Live Connect
2 Client-based WWW technologies
3 Inter-technology communication
4 Inter Language Capabilities
5 JavaScript to Java Communication
6 Example Java Code Accessed from JavaScript
7 The HTML and JavaScript to Access Example Java Code
8 Java to JavaScript communication
9 Example Java Code Accessing JavaScript
10 HTML Page Invoking Example Java Code
11 Java - native language communication
12 Java - native language communication
13 Java - plug-ins communication
14 JavaScript Plug-in Interaction Example
15 Java - plug-ins communication
16 Applet - plug-in communication
17 Wv plugin & applet installation
18 Wv plugin & applet run time
19 Plug-ins vs. LiveConnect

Outside Index Summary of Material



HTML version of Basic Foils prepared 2 October 98

Foil 1 Linking Web Software Components with Netscape's Live Connect

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
CPS640 Network and Multimedia Technologies
Spring 1998
Marek Podgorny
Nancy McCracken

HTML version of Basic Foils prepared 2 October 98

Foil 2 Client-based WWW technologies

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Java
  • Java is an architecture-neutral programming language, not necessarily bound with WWW.
Java applets
  • Applets are programs written in Java that are embedded in Web pages (subject to security constraints).
JavaScript
  • JavaScript is a cross-platform scripting language to be embedded directly in HTML page and interpreted by Web browsers.
Netscape plug-ins
  • Plug-ins are software modules that are seamlessly integrated into Navigator, appearing as supplemental capabilities of the browser.
Netscape LiveConnect
  • LiveConnect technology encompasses plug-ins as well as facilities for integrating plug-ins with Java and JavaScript.

HTML version of Basic Foils prepared 2 October 98

Foil 3 Inter-technology communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Native code - any language linkable with C
Java allows one to:
  • 1. call native methods from Java,
  • 2. call Java methods from native code.
  • This does not work (for security reasons) with applets.
LiveConnect allows one to:
  • 3. call Java methods from plug-ins,
  • 4. call native methods implemented in plug-ins from Java,
  • 5. call Java methods from JavaScript,
  • 6. call JavaScript from Java methods.
With some ingenuity, one can:
  • 7. call native methods from applets,
  • 8. call applet methods from native code.

HTML version of Basic Foils prepared 2 October 98

Foil 4 Inter Language Capabilities

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Browser entities communication capabilities
Browser entities cross-awareness

HTML version of Basic Foils prepared 2 October 98

Foil 5 JavaScript to Java Communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
JavaScript can directly call any public method defined in the applet and access any public data
JavaScript accesses the applet via the document object
JavaScript can be used, for instance, to debug applet's code by providing interactive interface to the applet's methods

HTML version of Basic Foils prepared 2 October 98

Foil 6 Example Java Code Accessed from JavaScript

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
import java.applet.*;
import java.awt.Graphics;
public class Hello extends Applet {
String str = "Hello, World";
int x = 25;
int y = 25;
public void paint ( Graphics g){
g.drawString ( str, x, y );
}
public void setString ( String newstr ){
str = newstr;
repaint();
}
public String getString() {
return str;
}

HTML version of Basic Foils prepared 2 October 98

Foil 7 The HTML and JavaScript to Access Example Java Code

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
<html>
<applet name=hello
code=Hello.class
width=200 height=100>
</applet>
<form >
<input name="In" type=text size=35>
<input type=button value="Set"
onclick="document.hello.setString(form.In.value)">
<br>
<input name="Out" type=text size=35>
<input type=button value="Get"
onclick="form.Out.value=document.hello.getString()">
</form>
</html>

HTML version of Basic Foils prepared 2 October 98

Foil 8 Java to JavaScript communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
JavaScript defines hierarchy of objects on HTML page.
These objects are accessible from Java via LiveConnect mechanisms implemented in netscape.javascript. JSObject class.
  • Example: JSObject.getWindow(this) method returns the root of the JavaScript hierarchy; JSObject.getWindow(this).getMember("document").getMember(frame_name) returns JSObject representing Netscape frame with parameter name=frame_name
JavaScript is aware of Java objects and can call their methods directly.
  • Example: <script>package.class.method();</script>

HTML version of Basic Foils prepared 2 October 98

Foil 9 Example Java Code Accessing JavaScript

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
import java.applet.*; import java.awt.*;
import netscape.javascript.JSObject;
public class SayThanks extends Applet {
JSObject win;
String str = "Click for an important message";
int x = 25; int y = 25;
public void paint ( Graphics g ) {
g.drawString ( str, x, y );}
public void init()
{ win = JSObject.getWindow(this);}
public boolean mouseUp(Event e, int x, int y)
{ JSObject document =
(JSObject) win.getMember ( "document" );
Object args[] = new Object[1];
String title =
(String) document.getMember ( "title" );
args[0] = "Thanks for visiting " + title;
win.call ( "alert", args );
return true;
}

HTML version of Basic Foils prepared 2 October 98

Foil 10 HTML Page Invoking Example Java Code

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
<html>
<title> My Web Page </title>
<applet code=SayThanks.class
width=200 height=100
mayscript=true >
</applet>
</html>

HTML version of Basic Foils prepared 2 October 98

Foil 11 Java - native language communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
The Java language uses native method modifier to declare a method implemented in another language.
The native signature of the method as well as wrapper functions are machine generated using program javah.
The class using native method needs to load the native library.

HTML version of Basic Foils prepared 2 October 98

Foil 12 Java - native language communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Example
  • create java class - file ex1.java:
    • public class ex1 {
    • public native int funct();
    • static{ System.loadLibrary("ex1.so"); }}
  • create java byte code ex1.class: javac ex1.java
  • create ex1.h header file for native code: javah ex1
  • create ex1.c stub - interface between ex1 Java class and C language: javah -stubs ex1
  • implement native method libex1.c:
    • #include ex1.h; funct() { ... }
  • compile ex1.c and libex1.c and link it into dynamic library ex1.so

HTML version of Basic Foils prepared 2 October 98

Foil 13 Java - plug-ins communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Java interface to plug-in is necessary!
Netscape provides netscape.plugin.Plugin class which is the Java representation of the native plug-in.
Specifics for particular plug-in subclass of java.plugin.Plugin must be created and installed together with plug-in itself (NPX_PLUGIN_PATH).
LiveConnect mechanism automatically instantiates Java class representing plug-in.

HTML version of Basic Foils prepared 2 October 98

Foil 14 JavaScript Plug-in Interaction Example

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
<head> <script language="JavaScript">
function doNothing() {} // A dummy function
function playSound ( soundName )
{ plugin = document.plugins[soundName];
window.status = soundName
if ( plugin != null )
{ plugin.StopAll();
plugin.play(false);
setTimeout('plugin.stop()', 2000); } }
</script>
<title> Sound Sampler </title></head> <body>
<h2> Point to an instrument to hear how it sounds</h2>
<embed src="keyboard.aiff" name="keyboard"
hidden=true volume= 100% autostart=false> ....
<a href="doNothing()"
onMouseOver="playSound('keyboard'); return true;">
<img src="keyboard.gif" border=0> </a> ....
</body></html>

HTML version of Basic Foils prepared 2 October 98

Foil 15 Java - plug-ins communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Communication between this object and the plug-in is done the same way as in general case of Java-native code communication, except for:
  • different javah program is provided by Netscape
    • Netscape javah is JRI - aware
  • one does not need to explicitly load the native library - all code is in the plug-in dynamic library which is loaded automatically when necessary (Java object creation follows plug-in load).

HTML version of Basic Foils prepared 2 October 98

Foil 16 Applet - plug-in communication

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
Communication between applet and plug-in is done via JavaScript.
Both java.applet.Applet and netscape.plugin.Plugin class can access JavaScript hierarchy and learn about each other.
  • Applet can call native methods against the security policy.

HTML version of Basic Foils prepared 2 October 98

Foil 17 Wv plugin & applet installation

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
libWvDecoder.so
WvDecoder.class
HTTP server
Web browser
NPX_PLUGIN_PATH
(LiveConnect capable)

HTML version of Basic Foils prepared 2 October 98

Foil 18 Wv plugin & applet run time

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
browser finds <embed> tag in HTML page
  • - libWvDecoder.so (plugin) is started
libWvDecoder.so calls use_WvDecoder(NPN_GetJavaEnv())
  • - WvDecoder.class is instantiated in decoder object
browser finds <applet> tag
  • - WvViewer.class is imported, and instantiated in viewer object
viewer calls Java Script: JSObject.getWindow(this).
  • .getMember("document").getMember("WvDecoder")
  • - decoder is returned to viewer
Communication is established:
  • - viewer can calls native methods from libWvDecoder.so via decoder,
  • - and vice versa - plug-in can calls any applet method.

HTML version of Basic Foils prepared 2 October 98

Foil 19 Plug-ins vs. LiveConnect

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. *
Full HTML Index
LiveConnect enables creation of externally callable interface to a plug-in
  • Without LiveConnect, plug-ins werea vehicle to display new data type
  • With LiveConnect, plug-ins become building blocks of larger applications
  • Right tools for every task:
    • Java is an ideal tool to build graphical interfaces
    • C remains the best language for CPU intensive tasks
  • Applets, plug-ins and LiveConnect eliminate most of architectural limitations for the browser-based apps

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Nov 29 1998