How can I use Linux shared libraries in Java?

前端 未结 3 640
梦如初夏
梦如初夏 2021-01-03 00:45

Is there any way to call the functions which are in a so library from my Java code? Generally, is it possible to use Linux so libraries in Java pr

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 01:40

    You cannot use arbitrary .so libraries in your Java code. You can use JNI to write a wrapper around native code to access from Java.

    However, be aware that doing so negates many of the advantages of using Java. Your code and deployment system now becomes quite fragile and subject to many types of bugs that cannot happen in Java. I would try quite hard to find a pure-Java solution before resorting to using native code.

提交回复
热议问题