This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI - using native data types in java code

 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm probably the only person in the world that wishes to do this but here goes. I have some C code which defines a few structures. I want to use these structures inside my java code but don't know how to represent them. There isn't any typedef or struct inside of java so I am clueless as to how to use them from within my java code. Does JNI support passing these types back and forth between java and native code?
Can classes be defined as native and defined in native code?
Thanks,
Frank
 
Pawel Veselov
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, classes can't be defined native.
As for structures - since Java doesn't have structures, you have to define a class with fields only and then access this fields copying data from/to your native structures.
You can't pass a custom structure to/from JNI.

------------------
With best of best regards, Pawel S. Veselov ( aka Black Angel )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic