What is the difference between System.load()
and System.loadLibrary()
in java?
I want to load a library but I don't want to add the path to environment variables. Will any one of these help?
The System. loadLibrary() takes as parameter a library name, locates a native library that corresponds to that name, and loads the native library. For information about how a native library is located by the System.
The UnsatisfiedLinkError is a sub-class of the LinkageError class and denotes that the Java Virtual Machine (JVM) cannot find an appropriate native-language definition of a method declared as native . This error exists since the first release of Java (1.0) and is thrown only at runtime.
java. library. path is a System property, which is used by Java programming language, mostly JVM, to search native libraries, required by a project. Similar to PATH and Classpath environment variable, java.
The difference is there in the API documentation. System.loadLibrary(String libname)
lets you load from the default path -- The Java library path.
The other System.load(String filename)
lets you load it from an absolute path, which you must specify as your filename.
If you don't want to mess with you java.library.path
environment variable, you should use System.load()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With