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?

- 32,079
- 16
- 104
- 187

- 975
- 2
- 16
- 29
-
If it was built for Android, it's probably compiled for ARM or something like that. ARM libraries won't run on PCs, unless they also have ARM CPUs. – Robin Green Dec 04 '18 at 22:57
-
Thanks for your answer, I found this video how import Visual C++ JNI dll in Eclipse, Eclipse has the option to import Native Library Location, but Netbeans has something equals? https://www.youtube.com/watch?v=R9oqGU6U_tI – Ejrr1085 Dec 04 '18 at 23:07
1 Answers
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.

- 975
- 2
- 16
- 29