dcsimg
AccessingJava 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:18 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; String overlapFile; String explosureFile; double thetaLBound; double thetaUBound; int explosureCont   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;

String overlapFile;

String explosureFile;

double thetaLBound;

double thetaUBound;

int explosureControl; //NOCONTROL, CONRANDOMESQUE, and SLC

int nThetaIEC; //number of theta ranges

double IECThetaRanges; //the theta ranges; for example, [0]~[1] as the first range

int randomesquePars;

int nMLEIters;

int nMLEFinalIters;

int nBFIters;

int nBFFinalIters;

double minDelta;

double finalMinDelta;

double infWeight;

double consWeight;

int testLength;

double startTheta;

double zeroThetas; //Thetasfor zero score

double perfectThetas; //Thetasfor perfect score
…..

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