wood burning stoves 2.0*
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
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: 19656
    
  18

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.
 
Similar Threads
Convert Integer List to int array
Problem in Arrays passing.
here is a question and i have a very similar code but i need to convert it
cant understand arrays
Collection Problem - binarySearch Problem