Right way to get the Method reference of the java in DLL using JNI Intreface?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   learner_always
Posted On:   Wednesday, November 29, 2006 05:33 AM

Hi! I want to call a method in Java file HelloWorld from thie CPP mentioned below. When i execute the main file which has a call to the native method displayHelloWorld,it shows me a Hotspot JVM error "EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0806a3c2, pid=3976, tid=4092 # # Java VM: Java HotSpot(TM) Client VM (1.4.2_12-b03 mixed mode) # Problematic frame: # V [jvm.dll+0x6a3c2] " Now if i comment the calls "GetMethodID" and "CallVoidMethod" everything is fine.I m not able to figure out y this is happeneing. Is the way i have written the calls right?Pls reply to this. // HelloWorld.cpp : Defines the entry point for the DL   More>>

Hi! I want to call a method in Java file HelloWorld from thie CPP mentioned below.
When i execute the main file which has a call to the native method displayHelloWorld,it shows me a Hotspot JVM error
"EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0806a3c2, pid=3976, tid=4092

#

# Java VM: Java HotSpot(TM) Client VM (1.4.2_12-b03 mixed mode)

# Problematic frame:

# V [jvm.dll+0x6a3c2]
"

Now if i comment the calls "GetMethodID" and "CallVoidMethod" everything is fine.I m not able to figure out y this is happeneing.
Is the way i have written the calls right?Pls reply to this.

// HelloWorld.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include
#include "HelloWorld.h"
#include

char newName = 'J';

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}


JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!
");

jclass myClass = (*env).GetObjectClass(obj);
jmethodID paramMID = (*env).GetMethodID(myClass,"setParameter","(Ljava/lang/Strin)V");


(*env).CallVoidMethod(obj,paramMID,newName);
return;
}

   <<Less
About | Sitemap | Contact