#include <stdio.h>
#include "Package_MyTester.h"
jstring Java_Package_MyTester_NMethod
(JNIEnv *env, jobject obj, jint first, jint second) {
jint result_i = first * second;
jstring result;
int x = 0;
for(x=0;x<5;x++) {
printf("%d",x);
}
return result;
}
This program multiplies two jints. The result has to be in jstring. Is there a way to convert jint to jstring ?.
You need to create a C buffer containing the result (using
sprintf) and then return the result of aNewStringUTFfunction:See §3.2.3 of http://java.sun.com/docs/books/jni/html/objtypes.html