• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI Call Object Methods  RSS feed

 
Parseval Adamsberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new here, so thanks for comments and advices. I hope I hit the correct list.


Problem:
I have two classes Graph and Node.

Now I want to realize the following Java Code by Call from C++. I will not use callbacks, because later I want to write a wrapper library:

Graph g = new Graph();
Node A = g.addNode();


I do this to create the Graph Object in c++:


#include <jni.h>
#include <stdio.h>
#include <iostream>
#include "GraphTest.h"



JNIEXPORT jobject JNICALL Java_GraphTest_getGraph
(JNIEnv* env, jclass in_cls)

{

jclass jcls;
jmethodID jmid;
jobject jobj;

jcls = env->FindClass("Graph");
jmid = env->GetMethodID(jcls, "<init>","()V");
jobj = env->NewObject(jcls, jmid);

return jobj;

}

How can I realize the second Part [[Node A = g.addNode();]] in c++ now?




Many in thanks in advance
Parseval

 
Parseval Adamsberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved it already myself


jmethodID jmid2 = env->GetMethodID(jcls, "addNode","()LNode;");
jobject jobj2 = env->CallNonvirtualObjectMethod(jobj,jcls, jmid2, "V");


cheers
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Parse Val",

Please read your private messages regarding an important announcement.

Thank you,

Rob
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!