Creating and Using Java Variables
Once you load the JAR file, you need to create a Java variable. You create a Java variable like any other Magic xpa variable, in the Data View Editor.
You need to set the Object Type property in the JAVA section.
Java variables need to be initialized manually by a constructor. A constructor instantiates and initializes an object. Constructors are methods in which the name of the method is the same as the class itself.
You can initialize a Java variable either by updating the Java variable with an existing Java object or by running a Java method that creates a Java object.
For example, update A with Java.java.lang.String();
Using a constructor is an operation that needs to be performed only once. If this is performed a second time, a new instance of the object is created. As a consequence, you need to take special care as to where to define the constructor.
Java variables in Magic xpa represent Java objects. The Java variable keeps only a reference to the Java object. Therefore, any properties of the Java object are not stored in the Magic xpa Java variable.
This means for example that:
ยท A Java variable should not be stored as a shared value using the SharedValSet() function. When using the SharedValSet() function for a Java variable, only the variable reference is stored as a shared value. This means that if the Java object was created in a task that is now closed, the reference stored in the shared value will refer to a non-existing object.