Skip to content

Commit 4ea9861

Browse files
committed
#882 Add support for loading native library from a user specified location
1 parent aee8a10 commit 4ea9861

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

c/src/main/java/org/apache/arrow/c/jni/JniLoader.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,24 @@ private synchronized void loadRemaining() {
7575
}
7676

7777
private void load(String name) {
78+
String libraryName = System.mapLibraryName(name);
79+
80+
// If 'arrow.cdata.library.path' is defined, try to load the native library from there
81+
String libraryPath = System.getProperty("arrow.cdata.library.path");
82+
if (libraryPath != null) {
83+
try {
84+
File libraryFile = new File(libraryPath, libraryName);
85+
if (libraryFile.isFile()) {
86+
System.load(libraryFile.getAbsolutePath());
87+
return;
88+
}
89+
} catch (UnsatisfiedLinkError e) {
90+
// Ignore this error and fall back to extracting from the JAR file
91+
}
92+
}
93+
7894
final String libraryToLoad =
79-
name + "/" + getNormalizedArch() + "/" + System.mapLibraryName(name);
95+
name + "/" + getNormalizedArch() + "/" + libraryName;
8096
try {
8197
File temp =
8298
File.createTempFile("jnilib-", ".tmp", new File(System.getProperty("java.io.tmpdir")));

0 commit comments

Comments
 (0)