try {
// Try to load natively first, this works on Android and in testing.
System.loadLibrary(\"lightningjni\");
try {
// Try to load natively first, this works on Android and in testing.
System.loadLibrary(\"lightningjni\");
// Otherwise try to load from the library jar.
File tmpdir = new File(System.getProperty("java.io.tmpdir"), "ldk-java-nativelib");
tmpdir.mkdir(); // If it fails to create, assume it was there already
// Otherwise try to load from the library jar.
File tmpdir = new File(System.getProperty("java.io.tmpdir"), "ldk-java-nativelib");
tmpdir.mkdir(); // If it fails to create, assume it was there already
Files.copy(is, libpath, StandardCopyOption.REPLACE_EXISTING);
Runtime.getRuntime().load(libpath.toString());
} catch (IOException e) {
Files.copy(is, libpath, StandardCopyOption.REPLACE_EXISTING);
Runtime.getRuntime().load(libpath.toString());
} catch (IOException e) {