What is the syntax for creating a .Net object from java code (NObject) when the constructor of the .Net object has one or more parameters?
Thanks
What is the syntax for creating a .Net object from java code (NObject) when the constructor of the .Net object has one or more parameters?
Thanks
On
I figured it out in case it wasn't obvious from the documentation
Add your reference to the dll using
Javonet.addReference()
Get the type (class name)
NType test = Javonet.getType("Namespace.Classname");
Call constructor with zero or more parameters
NObject obj = test.create(parameter1,parameter2, parameter3,.....etc);
The answer by erotavlas is correct although the syntax for classes is much simpler and can be done with a one-liner (https://www.javonet.com/java-devs/guides/creating-instance-calling-instance-methods/).
To create .NET object from Java you simply use:
Additional note if your class constructor has array parameter (of any type) you need to cast it to Object array.
Also, you can try new service that will create a strongly typed java wrapper for you (have a read here https://www.javonet.com/blog/more-about-javonet-io/)