These simple tests illustrate some of the new cross-platform Java/JavaScript ("LiveConnect") functionality being introduced in the new Java Plug-In with Java SE 6 Update 10.

In earlier versions of the Java Plug-In, functionality such as the ability to call static Java methods and create new Java objects from JavaScript was available, but only in the Mozilla family of browsers. With the introduction of the new Java Plug-In, this functionality and more is now available on all web browsers.

View the source of this web page to see the JavaScript code for the following examples. They rely on a no-op applet to bootstrap the process, the source code of which can be seen here.

The following test calls the static method java.lang.Integer.parseInt directly from JavaScript, demonstrating support for calling static methods and returning Java numbers in boxed form to the JavaScript engine.

The following test calls the static method java.lang.System.out.println from JavaScript.

The following test calls a static method in a non-core package, specifically javax.swing.JOptionPane.showMessageDialog.

The following test instantiates a Java object (an instance of java.lang.Integer) directly from JavaScript.

The following test demonstrates a more complex scripting scenario: it instantiates a javax.swing.JFrame, sets up its default close operation, adds a javax.swing.JTextField containing some text, and makes the frame visible, all from JavaScript. (Note that best practices would do this work on the Event Dispatch Thread, which is currently difficult to do without help from Java code; this is merely a proof-of-concept demonstration.)