1
package org.herac.tuxguitar.player.impl.midiport.coreaudio;
5
public class JNILibraryLoader {
7
private static final String JNI_EXTENSION = ".jnilib";
9
//private static final String JNI_TMP_PATH = (System.getProperty( "java.io.tmpdir" ) + File.separator);
11
public static void loadLibrary(String libname){
12
System.out.println("trying to load" + libname + " (void loadLibrary)");
13
JNILibraryLoader.loadFromClassPath(libname + JNI_EXTENSION);
15
if(!JNILibraryLoader.loadFromClassPath(libname + JNI_EXTENSION)){
16
//System.loadLibrary(libname);
21
private static boolean loadFromClassPath(String filename){
22
System.out.println("trying to load" + filename + " (bool loadFromClassPath)");
24
File file = new File(/*JNI_TMP_PATH +*/ filename);
28
OutputStream outputStream = new FileOutputStream(file);
29
InputStream inputStream = JNILibraryLoader.class.getClassLoader().getResourceAsStream(filename);
30
if (inputStream != null) {
32
byte [] buffer = new byte [4096];
33
while ((read = inputStream.read (buffer)) != -1) {
34
outputStream.write(buffer, 0, read);
42
System.out.println("calling file.getAbsolutePath() : "+ file.getAbsolutePath());
43
System.load(file.getAbsolutePath());
44
//System.load(file.getAbsolutePath());
49
System.out.println("Can't find file " + file.getAbsolutePath());
53
}catch(Throwable throwable){