How do you set Java library path programatically?
Java library path can be set by choosing an option as:-
-Djava.library.path=your_path
While setting the java.library.path property to "." instructs the Java virtual machine to search for native libraries in the current directory.
And you execute your code as :
If you want to load a library from a specific location, you can use System.load() instead with the full path to the library.
-Djava.library.path=your_path
While setting the java.library.path property to "." instructs the Java virtual machine to search for native libraries in the current directory.
And you execute your code as :
java -Djava.library.path=. HelloWorldThe "-D" command-line option sets a Java platform system property. But these values are 'read only' like many of the system properties, the value in java.library.path is just FYI and changing it doesn't actually change the behaviour of the JVM.
If you want to load a library from a specific location, you can use System.load() instead with the full path to the library.