giving 'java.library.path' in netbeans for .dll/.so files

*爱你&永不变心* 提交于 2019-11-26 04:55:42

问题


How do i give the path for the .dll or .so file in netbeans to load the library using

System.loadLibrary(\"Foo\")

I read this on netbeans page but couldn\'t help me. as it gives the unsatisfied link error.

These are the two things i tried :

In the following snapshot i created a lib folder inside the netbeans project and placed the dll files inside it.

\"enter

In the second snapshot i created a lib folder inside the modules folder and placed all the dll files inside lib folder as stated in the link.

\"enter

But both of them give me unsatisfied link error exception. How do i set java.library.path in netbeans so that i can directly test the application from netbeans, without having to go and write on the terminal ?


回答1:


Its working now. Some little bit setting you have to do with your Netbean IDE.Only of Netbean IDE.

Follow the Steps :-

==>Right click on the Project
==>Properties
==>Click on RUN
==>VM Options : -Djava.library.path="C:\Your Directory where Dll is present"
==>Ok

Its working 100%. I have done this in my own project.




回答2:


I'm using Mac OS X Yosemite and Netbeans 8.02, I got the same error and the simple solution I have found is like above, this is useful when you need to include native library in the project. So do the next for Netbeans:

1.- Right click on the Project
2.- Properties
3.- Click on RUN
4.- VM Options: java -Djava.library.path="your_path"
5.- for example in my case: java -Djava.library.path=</Users/Lexynux/NetBeansProjects/NAO/libs>
6.- Ok

I hope it could be useful for someone. The link where I found the solution is here: java.library.path – What is it and how to use




回答3:


IF you are working on "NetBeans Modules"

DLLs or SOs can be placed in the folder release/modules/lib/ in a module project's sources (look in the Files tab). This will make them appear in the final NBM or application in a lib subdirectory beneath where the module's JAR resides. Then just use System.loadLibrary as usual.




回答4:


To me JDeveloper's suggestion didn't work. However, the method that I came across this early afternoon works handy. It is for netbeans 8.02, and Visual Studio 2013 generated dll.

  1. create a package(eg, "dll") under [Source Packages] node of netbeans project
  2. put/copy a dll file(eg, simpleDLL.dll) into the package(eg, "dll")
  3. on the [Libraries] node of the netbeans project, right-click and choose "Add Jar/Folder...",
  4. navigate to the folder("src") that contains the folder("dll") for the package that you created in step 1 above (it could be "...\src\dll" in my example), select package folder("dll") and click [Open] button to select it.

-- now you should have added a folder("dll") (which contains the dll file{simpleDLL.dll}) to the Libraries node of the project.

That's it. It should work! Good luck.



来源:https://stackoverflow.com/questions/10714785/giving-java-library-path-in-netbeans-for-dll-so-files

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