JavaCallMethod Function

Action

Invokes either a dynamic or a static Java method. If parameters have been set with the JavaSetXX methods, these parameters will be passed to the method. To invoke static methods, the JAVA_STATIC_METHOD constant is passed instead of an object handle to the function. The method call will fail if no method signature matching the passed parameters is found.

Include file

Java.bdh

Syntax

JavaCallMethod( in hObject : number,
                in sMethod : string,
                in sTimerName      : string optional ): boolean;

Return value

  • true if the method call succeeded

  • false otherwise

Parameter Description
hObject Valid handle to a java object or JAVA_STATIC_METHOD.
sMethod

Name of the method to invoke for dynamic methods, or package/subpackage/class_name.static_method_name for static methods.

Example: toString

Example: java/lang/String.valueOf

sTimerName

(optional)

Creates a custom time measure with the specified name for this function.

Example

var
  hTestObj   : number; 

dcltrans
  transaction TInit
  begin
        // Load and start the JVM.
        JavaCreateJavaVM();

        // instantiate the java class
        hTestObj := JavaLoadObject("Test");
  end TInit;

  transaction THello
  begin
    JavaCallMethod(hTestObj, "doHello");
  end THello;

  transaction TEnd
  begin
    JavaFreeObject(hTestObj);
  end TEnd;

Sample scripts

JavaFrameworkBankSample.bdf

BankSample.java, Account.java, Customer.java, PremiumCustomer.java