I have a int array like
int[][] coordinates = {{346, 640, 499, 666},{555, 640, 675, 666}};
and I am trying to send this array to C with using JNI. I could find clear solution for one dimensional array but not for multidimensional array.
<br />
public class PopulateCoordinates{<br />
public native void Coordinates(int[][] coordinates);<br />
<br />
static {<br />
System.loadLibrary("libPopulateCoordinates");<br />
}<br />
public static void main(String[] args) {<br />
<br />
PopulateCoordinates h = new PopulateCoordinates();<br />
int[][] coordinates = {{346, 640, 499, 666},{555, 640, 675, 666}};<br />
h.Coordinates(coordinates);<br />
}<br />
}<br />
My C code has method which will populate its array that is passed from java like this
rect skip_rectarr[2] = { {346, 640, 499, 666}, { 555, 640, 675, 666 }};
<br />
typedef struct {<br />
int left;<br />
int top;<br />
int right;<br />
int bot;<br />
} rect;<br />
JNIEXPORT void JNICALL PopulateCoordinates_Coordinates(JNIEnv *env, jobject obj,jobjectArray inJNIArray)<br />
{<br />
}<br />
I am having a hard time in properly converting jobject to int[][] due to lack of native development knowledge. Can anyone tell me the simplest and safest possible way? Thanks