Tuesday, August 4, 2009

Interesting problem I encountered with JNI

I was trying to call C functions from java. Initially, I was sucessful in calling C function through java program. I thought everything was working well. But the problem is with the java code after calling the C function. I will present the summary of the problem

class testingC{
psvm(String args[]){
//declaration of native method and loading the library
testingC tc=new testingC();
//calling C function
tc.testingcores();
System.out.println("back to java program");
//creating file object
File f=new File("chandana.txt");
System.out.println("file created is:"+f);
}
}


When I run this program, I get the output
back to java program

when I don't call the C function, i.e I comment out tc.testingcores(),I get the output

back to java program
file created is chandana.txt.

I was very surprized to observe this. Why is the java code after calling the C function not working properly? The reason might be very simple. I don't know. I am trying to find out.

No comments:

Post a Comment