• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Objects and JNI  RSS feed

 
sandeep kumar jangra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello frenz... I have a problem regarding JNI.. i dont know C++ but i hv to implement JNI. actually i have got a driver program written in C++ for reading RFID cards. it have a method for reading the card. i.e
which takes parameter of type structure

typedef struct _RfidInfo {
unsigned int id;
unsigned int padding;
charname[64];
charivst[32];
chardummy[8];
}RfidInfo;

but since i cant use structures in java. how shud i call this native method from java. I have to set the values if i take any java object and how shud i give unsigned int..

plz help
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass the separate values to the native method which then creates a struct and puts the values in (may need conversion for some of them). Or you can create a Java class with these values which you retrieve the values from when creating the struct.

The important thing here is keeping the struct as an implementation detail and have communication with Java with Java types and classes.
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to write a C++ JNI funtion that will call the native function. You cannot call a native C++ function directly from java. You need a JNI function in between.
 
sandeep kumar jangra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Rob Spoor and Jayesh Lalwani........

I worked around some trick
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!