简体   繁体   中英

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

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".

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

Java 8支持静态链接的本机库http://openjdk.java.net/jeps/178

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM