How can I set the java.library.path
for a whole Eclipse Project? I\'m using a Java library that relies on OS specific files and need to find a .dll/
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
For a given application launch, you can do it as jim says.
If you want to set it for the entire workspace, you can also set it under
Window->
Preferences->
Java->
Installed JREs
Each JRE has a "Default VM arguments" (which I believe are completely ignored if any VM args are set for a run configuration.)
You could even set up different JRE/JDKs with different parameters and have some projects use one, other projects use another.
Just add the *.dll
files to your c:/windows
You can get the java.library.path from the follow codes:and then add you dll files under any path of you get
import java.util.logging.Logger;
public class Test {
static Logger logger = Logger.getLogger(Test.class.getName());
public static void main(String[] args) {
logger.info(System.getProperty("java.library.path"));
}
}
Click Run
Click Debug ...
New Java Application
Click Arguments tab
in the 2nd box (VM Arguments) add the -D entry
-Xdebug -verbose:gc -Xbootclasspath/p:jar/vbjorb.jar;jar/oracle9.jar;classes;jar/mq.jar;jar/xml4j.jar -classpath -DORBInitRef=NameService=iioploc://10.101.2.94:8092/NameService
etc...
If you are adding it as a VM argument, make sure you prefix it with -D
:
-Djava.library.path=blahblahblah...
Except the way described in the approved answer, there's another way if you have single native libs in your project.
java.library.path
.