Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNI - Returning value via output parameter

843829Apr 10 2006 — edited Apr 11 2006
Hi-

I have a piece of java code that looks like this:

public static String addMe(Double a, Double b, Double result) {
result = new Double(a.doubleValue() + b.doubleValue());
return "Addition worked!!";
}


As you can see I want to return the result of the function as a function parameter and have the function return variable be an info/error message.

I'm trying to call this via JNI, and I can get the return string to work.
But no matter what I try, I cannot get "result" to be returned populated.

I want to call Java FROM C.

I tried changing result to a double, Double, double[], and tried using jobject, jdouble, jdouble*, jdoubleArray, etc, on the C side.

I would love some help on this matter with some sample code.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2006
Added on Apr 10 2006
4 comments
847 views