How to set the java.library.path from Eclipse
Don't mess with the library path! Eclipse builds it itself!
Instead, go into the library settings for your projects and, for each jar/etc that requires a native library, expand it in the Libraries tab. In the tree view there, each library has items for source/javadoc and native library locations.
Specifically: select Project
, right click -> Properties / Java Build Path / Libraries tab, select a .jar, expand it, select Native library location, click Edit, folder chooser dialog will appear)
Messing with the library path on the command line should be your last ditch effort, because you might break something that is already properly set by eclipse.
How to add native library to java.library.path with Eclipse launch (instead of overriding it)
Had forgotten this issue... I was actually asking with Eclipse, sorry for not stating that originally.
And the answer seems to be too simple (at least with 3.5; probably with older versions also):
Java run configuration's Arguments : VM arguments:
-Djava.library.path="${workspace_loc:project}\lib;${env_var:PATH}"
Must not forget the quotation marks, otherwise there are problems with spaces in PATH.
How do I add external libraries to java.library.path in Eclipse?
See the answer at "How to set the java.library.path from Eclipse". Basically, there is a project configuration for "Native library location".
How to edit eclipse.ini to prepend existing java.library.path
After some more research and a few discussions with friends and colleagues, it seems that automatically extending the default java.library.path
in eclipse.ini
isn't possible. It seems you need to hard-code it.
I believe, however, just overwriting the old configuration is an undesirable way to go; one should at least extend the existing path. The following is a short description on how it was done on my system.
First, before modifying eclipse.ini
(i.e. without the -Djava.library.path=...
line), run eclipse, in the menu click "Help"->"About Eclipse", click "Installation Details", click on the tab "Configuration", wait until "retrieving system information..." disappears, scroll down to the second page and copy the line containing the java library path (in my case it is java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
).
Second, close eclipse, open eclipse.ini
, and append a line like -Djava.library.path=<added path>:<previous path>
. In my case this boils down to the line -Djava.library.path=/usr/lib/x86_64-linux-gnu/jni:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
.
Third, start eclipse again and check in the "Configurations" tab if the new path was properly set.
After this procedure my SVN plugin is working as desired. One hast to remember though to check the java.library.path
settings manually in case there are relevant changes to the system.
How can I set the java.library.path used by eclipse from a POM?
I've found that the eclipse m2e connector that goes with the maven-nativedependencies-plugin seems to fix this.
According to the mavennatives docs:
Since version 0.0.7 of the maven-nativedependencies-plugin if you have
m2eclipse installed and the nativedependencies plugin configured the
unpacking of natives will run automatically, you don't need the
eclipse plugin to unpack them. However in order to setup the
java.library.path environment variable in eclipse you will have to do
it either manually or automatically using the eclipse plugin.This Eclipse plugin is an extension to m2eclipse, it detects if you
have the maven plugin configured, and if you do it executes the
unpacking of natives, and configures the Native Library Location.If you import a maven project that has the mavennatives plugin
configured, and you have the m2eclipse integration plugin, on import
the natives will be extracted, also when performing a clean from
eclipse the natives will be extracted.So, if you use both these tools, using native dependencies requires no
manual configuration, other than whats in the pom, just run your app
and it works.
If I have the connector installed, and add mavennatives to my POM, then reload the pom (right-click on project in package explorer > maven > update project), the "Native library location" of the project is populated automatically (to see this, right click on project > properties > java build path > libraries > native library location)
This seems to work for debugging, JUnit runner, etc.
It does require that every developer install the plugin, which is manual (as manual as installing eclipse); however, at least once installed once it will work for any/all native depdendencies configured for mavennatives via a POM.
Related Topics
Why Do This() and Super() Have to Be the First Statement in a Constructor
How to Call One Constructor from Another in Java
Custom Thread Pool in Java 8 Parallel Stream
What Does "Possible Lossy Conversion" Mean and How to Fix It
How to Override Equals Method in Java
Calling Remove in Foreach Loop in Java
How to Return Multiple Objects from a Java Method
How to "Decompile" Java Class Files
How to Measure Time Elapsed in Java
Splitting a Java String by the Pipe Symbol Using Split("|")
What's the Difference Between Instant and Localdatetime
Difference Between Hashmap, Linkedhashmap and Treemap
Is There a Concise Way to Iterate Over a Stream With Indices in Java 8