Entry
Can JavaScript use Java classes?
Feb 26th, 2000 07:59
Martin Honnen, Netscape client side JavaScript reference and guide
With both NN3+ and IE4+ you can include a Java applet into your html
page and call its public methods with JavaScript in the page.
NN3 restrictedly and NN4 completely even allow to inline Java usage in
JavaScript e.g. you instantiate a Java Date object in JavaScript with
var javaDate = new java.util.Date()
The general syntax to create a Java object is
new Packages.packageName.ClassName()
where the
Packages.
prefix isn't needed for the
java.
sun.
netscape.
packages. Just keep a reference to the object e.g.
var object = new Packages.packageName.ClassName();
and then you can script the Java object from JavaScript e.g. call its
methods
object.methodName()
Note that client side JavaScript has the same security restrictions as
an applet so your code trying to access the local file system throws an
exception unless it first successfully request privilege to do so.
An example of a complete useful function using Java objects is
http://www.faqts.com/knowledge-base/view.phtml/aid/1268/fid/126/lang/en