How to set the java.library.path from Eclipse

2018-12-31 07:00发布

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/.so/.jnilib. But the Application always exits with an error message that those files are not found on the library path.

I would like to configure this whole project to use the library path. I tried to add the path as a VM argument to some run configurations in eclipse but that didn't work.

16条回答
笑指拈花
2楼-- · 2018-12-31 07:38

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.

查看更多
听够珍惜
3楼-- · 2018-12-31 07:45

Sometime we dont get Java Build Path by directly right click on project. then go to properties.... Right Click and go to properties

Then Click on java build pathProperties Scrren

Click on add external jar

Click on tab add external jars and give path of your computer file where u have stored jars.

查看更多
还给你的自由
4楼-- · 2018-12-31 07:47

Another solution would be to open the 'run configuration' and then in the 'Environment' tab, set the couple {Path,Value}.

For instance to add a 'lib' directory located at the root of the project,

    Path  <-  ${workspace_loc:name_of_the_project}\lib
查看更多
泪湿衣
5楼-- · 2018-12-31 07:47

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

查看更多
低头抚发
6楼-- · 2018-12-31 07:49

you can add vm argument in your eclipse.

Example : -Djava.ext.dirs=cots_lib

where cots_lib is your external folder library.

查看更多
步步皆殇っ
7楼-- · 2018-12-31 07:51

If you are adding it as a VM argument, make sure you prefix it with -D:

-Djava.library.path=blahblahblah...
查看更多
登录 后发表回答