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.
The following example is a computed field. It calls the Random
class
in java.util
.
var r = java.util.Random();
r.nextInt();
Take care with overloaded methods because JavaScript™ is typeless. For example:
class myClass {
myMethod(int val);
myMethod(double val);
}
In this case, you want to make the parameter an object that will be interpreted correctly on the Java™ side:
c.myMethod(new java.lang.Double(0.5));