Accessing Java Methods and Fields from c++ and vice versa
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ramesh_kesavanarayanan
Posted On:   Tuesday, January 29, 2008 02:47 PM

I have a java class (repr Structure in C++) public class CONFIG { private String log; public CONFIG(){ } private CONF confList; //FROM THE CONTROL FILE public CONF getConfList() { return confList; } public void setConfList(CONF confList) { this.confList = confList; } }; public class CONF { String itemParFile; String consFile; Geter and setter methods for all the above field } In my c++ program (implemented as per JINI specs) I do the following ofstream outdata; outdata.open(&qu   More>>

I have a java class (repr Structure in C++)


public class CONFIG {

private String log;

public CONFIG(){

}

private CONF confList; //FROM THE CONTROL FILE

public CONF getConfList() {

return confList;

}

public void setConfList(CONF confList) {

this.confList = confList;

}

};



public class CONF {

String itemParFile;

String consFile;

Geter and setter methods for all the above field

}



In my c++ program (implemented as per JINI specs) I do the following


ofstream outdata;

outdata.open("controlfile.dat");

/* Get a reference to object class */

jclass configCls = env->FindClass("CONFIG");

jmethodID oneCtorID = env->GetMethodID(configCls, " ", "()V");

jfieldID confListID = env->GetFieldID(configCls, "confList", "CONF");

outdata < < "----" < < < endl;

jobject newObject = env->NewObject(configCls,oneCtorID);

outdata < < "field to be set " < < configField < < endl;

outdata.close();


But I am getting the following exception
Exception in thread "main" java.lang.NoSuchFieldError: configObject

Can you let me know the correct syntax for getting a field and method calls and how can I set the same from c++ to Java    <<Less
About | Sitemap | Contact