Embedding Java in JavaScript
Java™ code can be embedded directly into JavaScript code.
- Java classes
Java classes can be accessed from JavaScript code by specifying the fully qualified name, for example, java.lang.Class or java.util.Random. The package containing the class must be available as a shared library on the server. The standard Java packages are available on all servers; other packages must be installed. - User classes
User Java classes can be created in an application using the Domino® or Java perspective, and called in JavaScript by specifying the fully qualified name. The class must belong to a package (not the default package). - Java arrays
Java arrays can be embedded in the JavaScript code without prior declarations or inclusions. This provides the ability to create multi-dimension arrays and to pass them as parameters to Java methods included in the JavaScript code. - JavaScript objects
A JavaScript object (when created with new Object()) is automatically converted to a map of properties when used as an argument to a Java method. A map is a Java interface that provides a list of name/value pairs. For example, you should pass a map when you call an XML adapter. - Parameter conversion
JavaScript parameters are passed by value (JavaScript arrays and objects used as parameters are not modified by the Java code). - JavaScript keywords and Java methods
You cannot use JavaScript keywords in Java syntax even if the word is legal in Java.
Parent topic: JavaScript language elements (JavaScript)