Example usage for java.lang System load

List of usage examples for java.lang System load

Introduction

In this page you can find the example usage for java.lang System load.

Prototype

@CallerSensitive
public static void load(String filename) 

Source Link

Document

Loads the native library specified by the filename argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.load("C:\\PHP\\bin\\php.exe");
    System.out.println("file gets loaded...");
}

From source file:viewer.Main.java

private static void loadLibrary() {
    try {//w  ww  .  j  a  va 2  s. com
        InputStream in = Main.class.getResourceAsStream("/opencv_java300.dll");
        File fileOut = File.createTempFile("lib", ".dll");
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
        System.load(fileOut.toString());
    } catch (Exception e) {
        throw new RuntimeException("Failed to load opencv native library", e);
    }

}

From source file:Main.java

/**
 * Load the libtango_client_api.so library based on different Tango device setup.
 *
 * @return returns the loaded architecture id.
 *///from   ww  w  .  ja  v a 2  s.  c o  m
public static final int loadTangoSharedLibrary() {
    int loadedSoId = ARCH_ERROR;
    String basePath = "/data/data/com.google.tango/libfiles/";
    if (!(new File(basePath).exists())) {
        basePath = "/data/data/com.projecttango.tango/libfiles/";
    }
    Log.i("TangoInitHelper", "basePath: " + basePath);

    try {
        System.load(basePath + "arm64-v8a/libtango_client_api.so");
        loadedSoId = ARCH_ARM64;
        Log.i("TangoInitHelper", "Success! Using arm64-v8a/libtango_client_api.");
    } catch (UnsatisfiedLinkError e) {
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "armeabi-v7a/libtango_client_api.so");
            loadedSoId = ARCH_ARM32;
            Log.i("TangoInitHelper", "Success! Using armeabi-v7a/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86_64/libtango_client_api.so");
            loadedSoId = ARCH_X86_64;
            Log.i("TangoInitHelper", "Success! Using x86_64/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86/libtango_client_api.so");
            loadedSoId = ARCH_X86;
            Log.i("TangoInitHelper", "Success! Using x86/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "default/libtango_client_api.so");
            loadedSoId = ARCH_DEFAULT;
            Log.i("TangoInitHelper", "Success! Using default/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.loadLibrary("tango_client_api");
            loadedSoId = ARCH_FALLBACK;
            Log.i("TangoInitHelper", "Falling back to libtango_client_api.so symlink.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    return loadedSoId;
}

From source file:brut.util.Jar.java

public static void load(String libPath) {
    if (mLoaded.contains(libPath)) {
        return;//from   w ww. j  ava  2  s. co  m
    }

    File libFile;
    try {
        libFile = getResourceAsFile(libPath);
    } catch (BrutException ex) {
        throw new UnsatisfiedLinkError(ex.getMessage());
    }

    System.load(libFile.getAbsolutePath());
}

From source file:Main.java

/**
 * Load the libtango_client_api.so library based on different Tango device setup.
 *
 * @return returns the loaded architecture id.
 *///from   w  w w .  j ava  2s .c  o m
public static final int loadTangoSharedLibrary() {
    int loadedSoId = ARCH_ERROR;
    String basePath = "/data/data/com.google.tango/libfiles/";
    if (!(new File(basePath).exists())) {
        basePath = "/data/data/com.projecttango.tango/libfiles/";
    }
    Log.i("TangoInitializationHelper", "basePath: " + basePath);

    try {
        System.load(basePath + "arm64-v8a/libtango_client_api.so");
        loadedSoId = ARCH_ARM64;
        Log.i("TangoInitializationHelper", "Success! Using arm64-v8a/libtango_client_api.");
    } catch (UnsatisfiedLinkError e) {
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "armeabi-v7a/libtango_client_api.so");
            loadedSoId = ARCH_ARM32;
            Log.i("TangoInitializationHelper", "Success! Using armeabi-v7a/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86_64/libtango_client_api.so");
            loadedSoId = ARCH_X86_64;
            Log.i("TangoInitializationHelper", "Success! Using x86_64/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86/libtango_client_api.so");
            loadedSoId = ARCH_X86;
            Log.i("TangoInitializationHelper", "Success! Using x86/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "default/libtango_client_api.so");
            loadedSoId = ARCH_DEFAULT;
            Log.i("TangoInitializationHelper", "Success! Using default/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.loadLibrary("tango_client_api");
            loadedSoId = ARCH_FALLBACK;
            Log.i("TangoInitializationHelper", "Falling back to libtango_client_api.so symlink.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    return loadedSoId;
}

From source file:Main.java

/** Carga una librer&iacute;a nativa del sistema.
 * @param path Ruta a la libreria de sistema.
 * @throws IOException Si ocurre alg&uacute;n problema durante la carga */
public static void loadNativeLibrary(final String path) throws IOException {
    if (path == null) {
        LOGGER.warning("No se puede cargar una biblioteca nula"); //$NON-NLS-1$
        return;/*from   w w  w  . j a  va  2 s. co  m*/
    }
    final int pos = path.lastIndexOf('.');
    final File file = new File(path);
    final File tempLibrary = File.createTempFile(
            pos < 1 ? file.getName() : file.getName().substring(0, file.getName().indexOf('.')),
            pos < 1 || pos == path.length() - 1 ? null : path.substring(pos));

    // Copiamos el fichero
    copyFile(file, tempLibrary);

    // Pedimos borrar los temporales cuando se cierre la JVM
    if (tempLibrary != null) {
        tempLibrary.deleteOnExit();
    }

    LOGGER.info("Cargamos " + (tempLibrary == null ? path : tempLibrary.getAbsolutePath())); //$NON-NLS-1$
    System.load(tempLibrary != null ? tempLibrary.getAbsolutePath() : path);

}

From source file:kyotocabinet.Loader.java

/**
 * Load the native library./*  w  ww.  j  a va  2s  .com*/
 */
static synchronized void load() {
    if (loaded) {
        return;
    }
    String lib = System.mapLibraryName("jkyotocabinet");
    if (lib.endsWith(".dll")) {
        // lib?lib
        URL url = Loader.class.getClassLoader().getResource(System.mapLibraryName("jkyotocabinet"));
        String libFileName = "./temp" + File.separatorChar + System.mapLibraryName("jkyotocabinet");
        File file = new File(libFileName);
        try {
            FileUtils.copyURLToFile(url, file);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.load(file.getAbsolutePath());
    } else {
        System.loadLibrary("jkyotocabinet");
    }
    loaded = true;
}

From source file:com.thenairn.linker.config.Libraries.java

/**
 * Puts library to temp dir and loads to memory
 *///ww w. j a v  a  2 s  .c  om
private static void loadLib(String path, String name) {
    name = name + ".dll";
    try {
        // have to use a stream
        InputStream in = Libraries.class.getResourceAsStream(LIB_BIN + name);
        // always write to different location
        File fileOut = new File(System.getProperty("java.io.tmpdir") + "/" + path + LIB_BIN + name);
        logger.info("Writing dll to: " + fileOut.getAbsolutePath());
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
        System.load(fileOut.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cc.recommenders.nativelibs.NativeLibLoader.java

public void loadLibrary(String library) {
    try {//from   ww  w  . j av a2s .co m
        String fileName = copyLibraryToTempFile(library);
        System.load(fileName);
    } catch (IOException e) {
        System.err.println("Could not find library " + library
                + " as resource, trying fallback lookup through System.loadLibrary");
        System.loadLibrary(library);
    }
}

From source file:org.apache.hadoop.fs.ceph.CephTalker.java

public CephTalker(Configuration conf, Log log) {
    System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so");
    System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
    cluster = 0;/*from   w  w  w . j  a v  a 2s . c o m*/
}