简体   繁体   中英

Import Android JNI shared library “.so” into Java Netbeans project?

I have a shared library, an .so library with a JNI interface. The .so library was built in Visual C++ 2017 with Android support. Now I want to import the .so library into a Java Netbeans project - is it possible?

Well, I got it with these posts:

http://electrofriends.com/articles/jni/jni-part1-java-native-interface/

http://electrofriends.com/articles/jni/part-2-jni-visual-studio-setup-dll-project/

Including Native Library in Netbeans

1.- Create JNI Library .dll or .so in Visual Studio with DLL project or C++ Library For Android, no empty Project and with JDK reference:

a.- In Visual Studio Go to Project->Properties.

b.- On the left side, select C/C++, add jdk include and win32 path in Additional Include Directories. If you have installed jdk in c program files then the path is

C:\\Program Files\\Java\\jdk1.6.0_18\\include; C:\\Program Files\\Java\\jdk1.6.0_18\\include\\win32

if JDK is 64 bits plataform the DLL must be compile to x64.

2.- In Netbeans:

a.-Right click on the Project Properties

b.- Click on RUN

c.- In VM Options TextBox add:

-Djava.library.path="C:\Your Directory where Dll is present".

c.- Finally call C++ method:

System.loadLibrary("JNILibreria");

The dll name complete is for example JNILibreria.dll.

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