IJavaUtils.Invoke

Syntax

Invoke(ClassName: String, MethodName: String, MethodSig: String, Params: Array): Variant;

Parameters

ClassName. Java class name in the file system or system module name in the JNI signature. When a Java class is specified, a file with the *.class extension is used in the file system. Parameter value is case sensitive.

MethodName. Name of executed method. Parameter value is case sensitive

MethodSig. JNI signature of method

Params. Array of parameter values sent to method.

Description

The Invoke method executes static Java method and returns result of its work.

Comments

To get a Java class in the file system and convert the file with the *.java extension to the file with the *.class extension, use the IJavaUtils.Compile method.

Example

Executing the example requires the Test.java file located in the file system at: D:/Work/Java/src/. The file should contain the Java code with the following class implementation:

public class Test {

    public static double staticFunc(double a, double b){

        return (a + b)/2;

    }

}

Add a link to the Java system assembly.

Sub UserProc;
Var
    JUtil: IJavaUtils;
    Result: Variant;
Begin
    JUtil := New JavaUtils.Create;
    JUtil.Compile("D:/Work/Java/src/Test.java");
    Result := JUtil.Invoke("Test""staticFunc""(DD)D"1.02.0);
    Debug.WriteLine(Result);
End Sub UserProc;

On executing the example, a Java function will be executed, which executes mathematical calculation based on the values sent in parameters. The function execution result will be displayed in the development environment console.

See also:

IJavaUtils