aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes jni: transfer a 2 dimension java array to c program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "jni: transfer a 2 dimension java array to c program." Watch "jni: transfer a 2 dimension java array to c program." New topic
Author

jni: transfer a 2 dimension java array to c program.

Kejia Jiarui
Greenhorn

Joined: Feb 21, 2012
Posts: 1
In Java, a 2 dimension array, Integer[][], is defined. How should one access the array arr in a C program via JNI?


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Through the default functions:
- GetFieldID to get a reference to the field.
- GetObjectField to get the field value.
- GetArrayLength to get the array length.
- GetObjectArrayElement to get the inner arrays and the Integers from them.

If you switch to an int[][] you must use GetIntArrayElements and ReleaseIntArrayElements to access the innermost elements.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jni: transfer a 2 dimension java array to c program.