6

so有没有办法从我的 Java 代码中调用库中的函数?一般来说,是否可以so在 Java 程序中使用 Linux 库?

4

3 回答 3

5

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.

于 2012-11-18T19:12:09.973 回答
4

除了 JNI 之外,从 java 访问库的​​另一种方法是JNA

我发现在很多情况下它比 JNI 更容易使用,但这只是我个人的看法。

于 2012-11-18T22:11:03.147 回答