4
4
import java .io .IOException ;
5
5
import java .io .InputStream ;
6
6
import java .nio .file .Files ;
7
+ import java .nio .file .Path ;
7
8
import java .util .Arrays ;
8
9
9
10
import org .apache .commons .lang3 .SystemUtils ;
@@ -92,7 +93,11 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
92
93
} else if (SystemUtils .IS_OS_MAC )
93
94
{
94
95
lib_name = "libBoardController.dylib" ;
95
- unpack_from_jar ("libneurosdk-shared.dylib" );
96
+ Path location = unpack_from_jar ("libneurosdk-shared.dylib" );
97
+ if (location != null )
98
+ {
99
+ System .load (location .toString ());
100
+ }
96
101
}
97
102
98
103
// need to extract libraries from jar
@@ -102,7 +107,7 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
102
107
instance = (DllInterface ) Native .loadLibrary (lib_name , DllInterface .class );
103
108
}
104
109
105
- private static void unpack_from_jar (String lib_name )
110
+ private static Path unpack_from_jar (String lib_name )
106
111
{
107
112
try
108
113
{
@@ -111,9 +116,11 @@ private static void unpack_from_jar (String lib_name)
111
116
file .delete ();
112
117
InputStream link = (BoardShim .class .getResourceAsStream (lib_name ));
113
118
Files .copy (link , file .getAbsoluteFile ().toPath ());
119
+ return file .getAbsoluteFile ().toPath ();
114
120
} catch (Exception io )
115
121
{
116
- System .err .println ("native library: " + lib_name + " is not found in jar file" );
122
+ System .err .println ("file: " + lib_name + " is not found in jar file" );
123
+ return null ;
117
124
}
118
125
}
119
126
0 commit comments