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

4

11

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 image description here

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 image description here

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 ?

Unwrap answered 23/5, 2012 at 6:45 Comment(1)
That only works for applications using the NetBeans platform, not for normal Java SE applications. Answer here: #8362228Asthenosphere
C
33

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.

Compelling answered 10/8, 2012 at 8:49 Comment(6)
How can you do this with 2 diffrent library paths? Say one in my desktop file and another in my program files, file?Airburst
Thanks, I found it works -Djava.library.path="path1";"path2" as well. Just a note to everyone who is reading this, Dont do what i did and enter the dll's name into the file path.Airburst
@JDeveloper : hello I am working in Ubuntu OS then how can be .dll workS?Luzern
@JavaMan ,I think .dll will not work on ubuntu or any unix flavour OS.You can configure the path using Build Path.Compelling
This doesn't work for me. Netbeans is still trying to look in the old location for the dll. What am I doing wrong?Consubstantial
in netbeans 8.2 for some reason it won't work without adding the word java in the beginning : java -Djava.library.path="C:\Your Directory where Dll is present"Claypan
P
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

Papillose answered 31/3, 2015 at 3:4 Comment(0)
P
1

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.

Perrins answered 13/6, 2015 at 4:59 Comment(0)
P
1

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.

Pedestrianism answered 1/12, 2017 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.