CreateJavaObject function
Syntax
CreateJavaObject(ClassName [ConstructorParams])
Where ConstructorParams has the form
argument1 [, argument2] . . .
Description
Use the CreateJavaObject function to create a Java object that can be manipulated in PeopleCode.
Note:
If you create a class that you want to call using GetJavaClass, it can be located in a directory specified in the PS_CLASSPATH environment variable or in other specified locations. The PeopleCode API Reference provides details on where you can place custom and third-party Java classes.
See PeopleCode API Reference: System Setup for Java Classes.
Use the CreateJavaObject function to create a Java array when you know how many values it should contain. If ClassName is the name of an array class (ending with [ ]), ConstructorParams are used to initialize the array.
In Java, do the following to initialize an array:
intArray = new int[]{1, 2, 3, 5, 8, 13};
Do the following to initialize such a Java array from PeopleCode:
&IntArray = CreateJavaObject("int[]", 1, 2, 3, 5, 8, 13);
To initialize a Java array without knowing the number of parameters until runtime, use the CreateJavaArray function.
Parameters
| Parameter | Description |
|---|---|
|
ClassName |
Specify the name of an already existing class. |
|
ConstructorParams |
Specify any construction parameters required for the class. Constructors are matched by construction parameter type and placement. |
Returns
A Java object.
Example
The following is an example of using dot notation and CreateJavaObject.
&CHARACTER.Value = CreateJavaObject(&java_path).GetField(&java_newchar).Value;
&NUMBER.Value = CreateJavaObject(&java_path).GetField(&java_newnum).Value;
&DATE.Value = CreateJavaObject(&java_path).GetField(&java_newdate).Value;