User`s manual
5 Calling Java from MATLAB
5-22
Using the javaMethod Function on Static Methods
The javaMethod function was introduced in section “Using the javaMethod
Function on Nonstatic Methods” on page 5-20. You can also use this function to
call static methods.
The following syntax invokes the static method,
method_name, in class,
class_name, with the argument list that matches x1,...,xn. This returns the
value
X.
X = javaMethod('method_name','class_name',x1,...,xn);
For example, to call the static isNaN method of the java.lang.Double class on
a double value of 2.2, you use
javaMethod('isNaN','java.lang.Double',2.2);
Using the javaMethod function to call static methods enables you to:
•Use methods having names longer than 31 characters
•Specify method and class names at run-time, for example, as input from an
application user
Obtaining Information About Methods
MATLAB offers several functions to help obtain information related to the
Java methods you are working with. You can request a list of all of the methods
that are implemented by any class. The list may be accompanied by other
method information such as argument types and exceptions. You can also
request a listing of every Java class that you loaded into MATLAB that
implements a specified method.
Methodsview: Displaying a Listing of Java Methods
If you want to know what methods are implemented by a particular Java (or
MATLAB) class, use the
methodsview function in MATLAB. Specify the class
name (along with its package name, for Java classes) in the command line. If
you have imported the package that defines this class, then the class name
alone will suffice.