1

I have a dll which has a method for e.g void abc(meth* myMeth) and a structure

struct meth
{
  int a;
  char b[255]; 
} 

The above code code is written in c. I need to map this to Java through JNI, and I am stuck. How can I pass a reference to the method abc as a pointer from a Java method, and how can I set the values of a and b and then pass back to Java again? Need An Urgent Help....Thanks

msm
  • 11
  • 4

2 Answers2

2

I do not know if this is an option for you, but consider using some higher level framework for managing the low-level details of JNI for you. Two options:

Personally I have used JNAerator and found it really helpful.

Neeme Praks
  • 8,956
  • 5
  • 47
  • 47
1

There is no mapping between Java classes and C structs (not sure about how JNA handles this); you'll have to create a Java class with the same members as your C struct and write C functions to convert between them.

lhballoti
  • 806
  • 7
  • 17