开发者

JAVA can invoke the .so file on linux platform?

开发者 https://www.devze.com 2023-02-26 05:18 出处:网络
I want to invoke the API provided by a\".so\" file in a JAVA project. CanJAVA call the .so file on linux platform? Anyone开发者_运维技巧 could provide a solution? Thank you very much!

I want to invoke the API provided by a ".so" file in a JAVA project. Can JAVA call the .so file on linux platform? Anyone开发者_运维技巧 could provide a solution? Thank you very much!


Can JAVA call the .so file on linux platform?

There are two ways to do this:

  • JNI allows you to declare methods as native in Java, and implement then in some other language (typically C or C++) and provide them as ".so" files. However, you can't do this for any old ".so" file, because Java expects the methods in the ".so" to have JNI specific signatures.

  • JNA allows you to call methods in arbitrary native libraries. You write Java code that provides a "native library declaration" to match the native methods' signatures, and the JNA infrastructure deals with the data type mapping, etc.


Yes, via JNI.

0

精彩评论

暂无评论...
验证码 换一张
取 消