added a class I found to load JNI code from within JAR files on non-android platforms.

That doesn't come for free, unlike android.
This commit is contained in:
Grant Limberg 2015-04-30 21:50:05 -07:00
parent 52df59c552
commit 75d7137025
2 changed files with 112 additions and 1 deletions

View file

@ -31,13 +31,31 @@ import java.nio.ByteBuffer;
import java.lang.Long;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.io.IOException;
/**
* A ZeroTier One node
*/
public class Node {
static {
System.loadLibrary("ZeroTierOneJNI");
try {
System.loadLibrary("ZeroTierOneJNI");
} catch (UnsatisfiedLinkError e) {
try {
if(System.getProperty("os.name").startsWith("Windows")) {
System.out.println("Arch: " + System.getProperty("sun.arch.data.model"));
if(System.getProperty("sun.arch.data.model").equals("64")) {
NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win64.dll");
} else {
NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win32.dll");
}
} else {
// TODO: Mac
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
private static final String TAG = "NODE";