I would like to call a method through a native java interface, which returns an object.
This is my native method
public native Node getProjectionPoint(double lat, double lon);  
Node class
 public class Node {        
    private String id;
    private double latitude;
    private double longitude;
}
C header file
JNIEXPORT jobject JNICALL Java_org_smartcar_serverdatainterface_shared_services_CppConnector_getProjectionPoint (JNIEnv *env, jobject obj, jdouble lat, jdouble lon);
How could I create an object and return it to java?
I sort out the problem
JNIEXPORT jobject JNICALL Java_org_smartcar_serverdatainterface_shared_services_CppConnector_getProjectionPoint
  (JNIEnv *env, jobject obj, jdouble lat, jdouble lon)
{
    jclass class = (*env)->FindClass(env,"org/smartcar/serverdatainterface/shared/businessentities/Node");
    if (NULL == class)
        PrintError ("class");
    jmethodID cid = (*env)->GetMethodID(env,class, "<init>", "(DD)V");
   if (NULL == cid)
       PrintError ("method");
   return (*env)->NewObject(env, class, cid, lat, lon);
}
this works perfectly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With