I don't understand what you mean. Are you trying to provide a Java implementation of the C++ code or are you trying to call the C++ code from your Java code.
Unfortunately the Java code you have shown makes little sense unless you show/explain what a JIString is and what object type 'dispatch' is and what it's callMethod() method does.
I don't understand what you mean. Are you trying to provide a Java implementation of the C++ code or are you trying to call the C++ code from your Java code.
Hello Keang,
I am just trying to do a java implementation of the C++ code, i want to write the same function in Java too. I am not calling any Cpp code
Unfortunately the Java code you have shown makes little sense unless you show/explain what a JIString is and what object type 'dispatch' is and what it's callMethod() method does.
Forget about the code, my aim is to implement the same function in Java too. In the JI is J-Interop "http://j-interop.org/".
If JIString is based on java.lang.String then it is immutable and so you can't change its contents. You will either have to return the new value from the method or pass in an object that can be changed or pass in a object that has a callback method (normally done by implementing an interface defining the callback method).
Ok let me understand this!! Are you talking about the Cpp functions, so if i have a Cpp method(implemented for the COM server lets say GetProjectNameForJava) which can return a string value, then i can use this PerfromOp function:
Code:
private void PerformOp() throws JIException
{
JIString outStr = new JIString("");
dispatch.callMethod("GetProjectNameForJava", new Object[]{outStr});
System.out.println("Out String = "+outStr.toString();
}
to call GetProjectNameForJava method. Do you think this would then populate outStr with my project name?
The problem is the dispatch.callMethod(). It presumably (I don't know for certain as I haven't seen the code for it) is expecting to call a method with the given name and which accepts a parameter of the given type. Your new method doesn't accept a parameter.
You either need to find a dispatch method that returns the value returned by the method call or use the second approach I outlined.
Bookmarks