Is it possible to link a static library to Java through JNI?

↘锁芯ラ 提交于 2019-11-30 04:37:44

问题


Is it possible to build a HelloWorld.lib and load it to a Java application using JNI? Or it just works with shared libraries?

I couldn't find a clear answer on the JNI documentation, there's no reference to "static library".


回答1:


It needs to be a dynamic library. Fortunately, you can build a dynamic library from a static one.




回答2:


Java 8 supports statically linked native libraries http://openjdk.java.net/jeps/178




回答3:


To load a library at runtime it must be a dll (windows). If you have a static library (lib) and you have to use it via JNI you have to create a wrapper dll




回答4:


You would have to link it to the JVM, and you don't have a way to do that. That's why JNI is defined with shared libraries, not static ones.



来源:https://stackoverflow.com/questions/15433684/is-it-possible-to-link-a-static-library-to-java-through-jni

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!