Example: To Create an Instance of a Class
This example shows how to create an instance of a class:
1
<java:new class="com.foo.Person" constructor="Person()"/>
This example shows how to create an instance using the default constructor. You can also use a non-custom constructor.
1
2
3
<java:new class="com.foo.Person" constructor="Person(String, Integer)">
<java:args>#[{name: 'MG', age: 34}]</java:args>
<java:new>
Note that you will get DataSense on the operation’s output (in this case a Person
object), and you will 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. |