This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 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: 19896
    
  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.