• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in native calling  RSS feed

 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm developing an application in which I have to do some native interaction on Linux.
I have following files

susi_lib_api.h
contents of that file
void SUSILVDSPanelOn(void);
void SUSILVDSPanelOff(void);

I also got
libsusi_PIT1702.so

the files I mentioned are already available.

Is anything else is required to run the program which will just call java code.




 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to create a Java class with native methods. Then using javah you need to create a header file for that Java class, and you need a .c or .cpp file that includes both the created header file and the susi_lib_api.h file. In this .c / .cpp file you implement the methods defined in the created header file; the implementation is basically just calling these methods. You then need to compile the .c / .cpp file as a shared library. This process of implementing a native method in a language like C or C++ is called JNI.
 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but I already have the
libsusi_PIT1702.so
file which is a dynamic link library...

what is use of this .so file.
as you are saying
the implementation is basically just calling these methods. You then need to compile the .c / .cpp file as a shared library. This process of implementing a native method in a language like C or C++ is called JNI.

but the process you have mentioned is to create shared library.



 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The .so shared library you have cannot be accessed from Java directly. This is where the JNI library comes in - it will form a bridge between the JVM and the existing .so library.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!