-Djava.library.path and System.setProperty

I have searched a bit before asking. I use netbeans. In my project, I use Slick and so lwjgl.
When I use-Djava… it works very well. on the other hand, when I use System.setProperty(“java.library.path”, “identic path”)

IT give me the same path but lwjgl doesn’t load…it said me unsatisfiedlink error no lwjgl in java.lib…
why?
my first line of the main is setProperty… ???

its cool to develop but if my programme does not run out of the IDE its useless… :-\

someone can give me a clue? or explain to me why?
my main class

Unfortunately simply calling setProperty() doesn’t do the trick. There was a lengthy thread about this, leading to this solution

thanks it’s very helpful, its work ^^ (for the moment ;D) I ’ ll modify it to be more adapted to my needs.

The above seems like a very hacky way to solve the problem.

Since you are using LWJGL you can simply use

System.setProperty("org.lwjgl.librarypath", path);

instead of “java.library.path” to make it work.

yes it work too and is more simply but I need more than lwjgl… Jinput too and in future, need others too so I think the hacky way is better when you need more than one or two natives sources

If you use your own classloader to load the classes that you don’t control that are loading native libs, then you can override ClassLoader#findLibrary to control where the native libs are found.

for Jinput you can use

System.setProperty("net.java.games.input.librarypath", path);

however, if you need more natives then that, then cylabs method above should work pretty well.

I have not think about it… I do not control on what is loaded…

@kapta : Where did you find thoses lines of property which are very simple to use and maintain… Where did you find the key string associated to the native ?

in the source code for the two libraries, when I was looking for similar functionality.

Thanks I have not thinked about looking in source code ::slight_smile:
With a line like that its more easy to maintain the code and to read it ;D