views:

30

answers:

1

System.setProperty("java.library.path", "pathToLibs");

doesnt work because it seems either "java.library.path" is read only or JVM just ignores the property.

I know it can be done by setting PATH(in windows), LD_LIBRARY_PATH(in POSIX) or just use the command java -Djava.library.path=your_path.

But is there a programming way of doing this?

+4  A: 

java.library.path is evaluated when the VM starts, so changing it later does not have any effect on loading native libraries. You can however use System.load(String filename); to specify the complete path to the native library you want to load, perhaps together with System.mapLibraryName(String) to add the platform specific file ending (e.g. .dll or .so).

jarnbjo