Skip to content

Commit

Permalink
try harder to fix sip issue for java
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 committed Apr 22, 2020
1 parent 062218c commit e264a35
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions java-package/brainflow/src/main/java/brainflow/BoardShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;

import org.apache.commons.lang3.SystemUtils;
Expand Down Expand Up @@ -92,7 +93,11 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
} else if (SystemUtils.IS_OS_MAC)
{
lib_name = "libBoardController.dylib";
unpack_from_jar ("libneurosdk-shared.dylib");
Path location = unpack_from_jar ("libneurosdk-shared.dylib");
if (location != null)
{
System.load (location.toString ());
}
}

// need to extract libraries from jar
Expand All @@ -102,7 +107,7 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
instance = (DllInterface) Native.loadLibrary (lib_name, DllInterface.class);
}

private static void unpack_from_jar (String lib_name)
private static Path unpack_from_jar (String lib_name)
{
try
{
Expand All @@ -111,9 +116,11 @@ private static void unpack_from_jar (String lib_name)
file.delete ();
InputStream link = (BoardShim.class.getResourceAsStream (lib_name));
Files.copy (link, file.getAbsoluteFile ().toPath ());
return file.getAbsoluteFile ().toPath ();
} catch (Exception io)
{
System.err.println ("native library: " + lib_name + " is not found in jar file");
System.err.println ("file: " + lib_name + " is not found in jar file");
return null;
}
}

Expand Down

0 comments on commit e264a35

Please sign in to comment.