JavaInvokeModule

Syntax

JavaInvokeModule(ModuleId,ClassName,MethodName,MethodSig,Param,…)

Parameters

ModuleId. Java module identifier in repository.

ModuleName. Java class name in the file system or the system module name in the JNI signature. When specifying the Java class in the file system, the file with the *.class extension is used.

MethodName. Name of executed method.

MethodSig. JNI signature of method.

Param1, Param2, …, ParamN. Parameters sent to the method.

NOTE. To determine signatures in Java Native Interface (JNI) format, review the signature generation rules.

Description

It returns the result of static Java method execution.

NOTE. Before using the function, make sure that integration of Foresight Analytics Platform with Java is executed.

Comments

The function can contain several parameters. New formulas are added automatically in the formula wizard after the user puts the cursor into the field with parameter. If extra parameters are added, they should be left empty. If the function contains no parameters, leave the Param field empty.

Keep in mind the following when calling a Java function:

TIP. For details about writing functions in the Java language, see Java documentation.

Example

Consider the Java code contained in the Java module with the MOD_JAVA identifier:

public class math {
   public static double staticFunc(double a, double b){
       return (a + b)/2;
   }
}

The table contains examples of formulas using the JavaInvokeModule function:

Formula Result Description
=JavaInvokeModule("MOD_JAVA", "math", "staticFunc", "(DD)D", 4.0, 2.0) 3.0 The staticFunc arithmetic function is executed in the class named math. Parameters of real types are specified in the function - the a variable is set to 4.0, the b variable is set to 2.0. The method returns arithmetic function calculation result.
=JavaInvokeModule("MOD_JAVA", "math", "staticFunc", "(DD)D", C3, C4) 5.0 The staticFunc arithmetic function is executed in the class named math. Parameters of real types are specified in the function - the a variable is set to the value specified in the C3 cell, the b variable is set to the value specified in the C4 cell. The C3 cell contains the 4.0 value, the C4 cell contains the 6.0 value. The method returns arithmetic function calculation result.

See also:

Function Wizard │ Functions for Working with Java