• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I pass a C pointer to a byte array and its length to Java

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How can I pass a C pointer to a byte array and its length to Java using JNI?
The example I find are just passing integer. How can I pass a byte array and its length?

Thank you for any pointers.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This chapter here (see 3.3) says about arrays in the JNI programming. If you want to return byte[] from a Java method (the array will internally have its length, so you don't need to pass it separately), try to compile it with javah and see what comes out. Then, using the methods described in the JNI Programmer's Guide you can convert the C array to a JNI-Java array and return it.

Thank you for any pointers.


Nice pun
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More suitable for "Other java APIs" forum.
Moving
 
reply
    Bookmark Topic Watch Topic
  • New Topic