The Artima Developer Community
Sponsored Link

Jini Forum
Calling Java Methods and Fields from c++

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ramesh Kesavanarayanan

Posts: 1
Nickname: kesavrames
Registered: Jan, 2008

Calling Java Methods and Fields from c++ Posted: Jan 29, 2008 11:14 AM
Reply to this message Reply
Advertisement
Hi all,

I have a java class (repr Structure in C++)
public class CONF {
String itemParFile;
String consFile;
String overlapFile;
String explosureFile;
}

public class CONFIG {
private CONF confList;
}

My java program which calls the c++ dll is as follows
public class CatAlgorithm {
public CONFIG configObject;
public CONFIG getConfigObject() {
return configObject;
}

public void setConfigObject(CONFIG configObject) {
this.configObject = configObject;
}
}

In my c++ program 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, "<init>", "()V");
jfieldID confListID = env->GetFieldID(configCls, "confList", "Ljava/lang/Object;");
outdata << "field to be set " << confListID << endl;
jclass catAlgoCls = env->FindClass("CatAlgorithm");
jfieldID configField = env->GetFieldID( catAlgoCls, "configObject","Ljava/lang/Object;");
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 some one let me know the correct syntax for getting a field and method calls and how can I set the same from c++ to Java

Topic: 2d barcode Previous Topic   Next Topic Topic: Strange Registrar behavior on Linux

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use