Contact Free trial Login

Example: To Create an Instance of a Class

This example shows how to create an instance of a class:

<java:new class="" constructor="Person()"/>

This example shows how to create an instance using the default constructor. You can also use a non-custom constructor.

<java:new class="" constructor="Person(String, Integer)">
      firstName: 'MG',
      age: 34
When configuring the constructor arguments in the args parameter, the keys of the map will identify which parameter should be invoked. In order to reference the parameters by name (firstName, age, etc.), the java class containing the Method or Constructor has to be compiled using the -parameters compiler flag. If the class was not compiled with this flag, then the same parameters should be refenced in the canonical way as arg0, arg1, etc.

Note that you will get DataSense on the operation’s output (in this case a Person object), and you will use DataSense to help you build the arguments map.

The classes used with the Java Module must be exported, if not the execution will fail with a JAVA:CLASS_NOT_FOUND error. See How to export resources.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub