Returning C++ Object - JNI
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   imran_rahman
Posted On:   Wednesday, March 31, 2004 09:33 PM

I want to send a C++ object from C++ to java using JNI. Sample is below. <#include "jni.h" <#include "OBjectPointerPassing.h" <{ < int b; < MyClass() < { < a = 123; < b = 345; <} <}; <*, jobject) <{ < MyClass obj ; < return ((jobject)&obj); <} { int a; int b; }; public class OBjectPointerPassing e   More>>

I want to send a C++ object from C++ to java using JNI.


Sample is below.





<#include "jni.h"

<#include "OBjectPointerPassing.h"



<{





< int b;


< MyClass()

< {

< a = 123;

< b = 345;

<}

<};




<*, jobject)

<{

< MyClass obj ;

< return ((jobject)&obj);

<}











{

int a;

int b;

};

public class OBjectPointerPassing extends JFrame

{

private native MyClass getTheObjectPointer();


static

{

System.loadLibrary("OBjectPointerPassing");

}

public static void main(String args[])

{

System.out.println("Am in Java Program");

OBjectPointerPassing Obj = new OBjectPointerPassing();

MyClass obj = Obj.getTheObjectPointer();

System.out.println("OutPut is "+obj.a +obj.b );


}

}



I am getting some exception. How to achive it?

   <<Less
About | Sitemap | Contact