The program core dumps while exiting from the C routine in a JNI call.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kaustubh_Patil
Posted On:   Thursday, August 22, 2002 09:38 PM

I am a novice in JNI. I had written a small trial JNI program that calls a simple c routine. The C routine does nothing but prints a simple line. Everything works fine. The shared library is loaded correctly, even the statement that i print inside the C routine is printed properly. But while exiting from the C routine the program core dumps. I tried a lot but could not understand the cause of the problem. i am posting the source code below... 1. The c code is ------------------------------------------- #include #include"NativeCall.h" void Java_NativeCall_printSomething(JNIEnv * ptr,jobject obj) { printf("Inside the native C    More>>


I am a novice in JNI. I had written a small trial JNI program that calls a simple c routine. The C routine does nothing but prints a simple line.
Everything works fine. The shared library is loaded correctly, even the statement that i print inside the C routine is printed properly.

But while exiting from the C routine the program core dumps.
I tried a lot but could not understand the cause of the problem.



i am posting the source code below...
1. The c code is
-------------------------------------------
			
#include
#include"NativeCall.h"

void Java_NativeCall_printSomething(JNIEnv * ptr,jobject obj)
{
printf("Inside the native C function..");
}

---------------------------------------------


2. The Java source code is
---------------------------------------------
			
public class NativeCall{
static{
System.loadLibrary("java-rtl");
}
public native void printSomething();
public static void main(String[] args){
try{
NativeCall nc = new NativeCall();
System.out.println("now calling the native method..");
nc.printSomething();
}catch(Exception e){
e.printStackTrace();
}
}
}



--------------------------------------------


I would appreciate any help.


Thanks,

Kaustubh    <<Less
About | Sitemap | Contact