File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kejia Jiarui
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic