• 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

problem in native calling

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic