I am running a java program which calls a native C function and returns back. The native code is getting executed but after returning back to the java program, the variables are not identified.
Let me explain,
My java program is like,
psvm(String args[]){
int n=10;
System.out.println("n value is:"+n);
//code for calling the C-Function
System.out.println("back to java program");
System.out.println("n value is:"+n);
//other code
}
When I run this program, the output is,
n value is:10
back to java program
The problem is that the program is not identifying "n" after returning back and the "//other code" is not executed. Also no error or exception is shown.
Can anyone help me.
native void testingcores(int int1,int int2);
static {
System.load("C:\\Microsoft Visual Studio 9.0\\VC\\Cprogram.dll");
}
public static void main(String[] args) {
int n=Integer.parseInt(args[1]);
System.out.println("jobs to be created is:"+n);
testingC tc=new testingC();
for(int i=1;i<=n;i++){
tc.testingcores(i,i+(i*100));
}
System.out.println("All jobs are started ");
System.out.println("jobs"+n+"started);
}
java testingC 5 5
then OUTPUT is,
jobs to be created is 5.
All jobs started.
The problem is that when it encounters a variable("n" in this case), it is not recognizing it. So,the last statement is not printed.
This code should never cause any problems. All I can think of is some bug in your native code. Can you show the native code for testingcores?
And while you're at it, please Use Code Tags.