https://github.com/fracpete/loadlib4j
Little helper class for testing the loading of native libraries in Java.
https://github.com/fracpete/loadlib4j
java library-loader
Last synced: over 1 year ago
JSON representation
Little helper class for testing the loading of native libraries in Java.
- Host: GitHub
- URL: https://github.com/fracpete/loadlib4j
- Owner: fracpete
- License: gpl-3.0
- Created: 2018-03-09T23:41:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-12T22:35:00.000Z (over 5 years ago)
- Last Synced: 2024-10-19T12:15:58.978Z (over 1 year ago)
- Topics: java, library-loader
- Language: Java
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loadlib4j
Little helper class for testing the loading of native libraries in Java.
It simply uses the `java.lang.System.loadLibrary(String)` call to load the
library.
## Usage
### Command-line
The following command tries to load the `libmkl_rt.so` library on Linux,
which has to be on the path defined by `LD_LIBRARY_PATH`:
```bash
java -jar loadlib4j-0.0.1.jar libmkl_rt.so
```
The output on stdout will be something like this:
```
libmkl_rt.so: false
libmkl_rt: false
mkl_rt: true
```
As you can see, loadlib4j also tries the library name without extension
and `lib` prefix. In the above example, the test succeeds with `mkl_rt`.
### Java
The same example in Java:
```java
import com.github.fracpete.loadlib4j.Main;
import java.util.Map;
...
// the libraries to test
String[] libs = new String[]{"libmkl_rt.so"};
Main test = new Main();
Map result = test.testLoading(libs);
// do something with the results, eg output them
for (String lib: result.keySet()) {
System.out.println(lib + " -> " + result.get(lib));
}
```
In this case, the output will be something like this:
```
libmkl_rt.so -> false
mkl_rt -> false
libmkl_rt -> false
```
## Releases
* [0.0.1](https://github.com/fracpete/loadlib4j/releases/download/v0.0.1/loadlib4j-0.0.1.jar)
## Maven
Use the following dependency to include the library in your Maven project:
```xml
com.github.fracpete
loadlib4j
0.0.1
```