简体   繁体   English

将Android JNI共享库“ .so”导入Java Netbeans项目吗?

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

I have a shared library, an .so library with a JNI interface. 我有一个共享库,一个带有JNI接口的.so库。 The .so library was built in Visual C++ 2017 with Android support. .so库是在具有Android支持的Visual C ++ 2017中构建的。 Now I want to import the .so library into a Java Netbeans project - is it possible? 现在,我想将.so库导入Java Netbeans项目-可以吗?

Well, I got it with these posts: 好吧,这些帖子让我明白了:

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

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

Including Native Library in Netbeans 在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: 1.-在带有DLL项目或C ++库的Visual Studio中创建JNI库.dll或.so对于Android,没有空的项目并且具有JDK参考:

a.- In Visual Studio Go to Project->Properties. 在Visual Studio中,转到“项目”->“属性”。

b.- On the left side, select C/C++, add jdk include and win32 path in Additional Include Directories. b.-在左侧,选择C / C ++,在Additional Include Directories中添加jdk include和win32路径。 If you have installed jdk in c program files then the path is 如果您已在c程序文件中安装了jdk,则路径为

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

if JDK is 64 bits plataform the DLL must be compile to x64. 如果JDK是64位平台,则DLL必须编译为x64。

2.- In Netbeans: 2.-在Netbeans中:

a.-Right click on the Project Properties 右键单击项目属性

b.- Click on RUN b。-单击运行

c.- In VM Options TextBox add: c.-在VM Options TextBox中添加:

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

c.- Finally call C++ method: c。-最后调用C ++方法:

System.loadLibrary("JNILibreria");

The dll name complete is for example JNILibreria.dll. 完整的dll名称例如是JNILibreria.dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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