Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between System.load() and System.loadLibrary in Java

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?

like image 540
javaMan Avatar asked Aug 10 '11 19:08

javaMan


People also ask

What does system loadLibrary do?

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.

What is Java Lang UnsatisfiedLinkError?

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.

What is Java library path?

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.


1 Answers

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()

like image 129
Kal Avatar answered Sep 22 '22 17:09

Kal