Example usage for java.lang System loadLibrary

List of usage examples for java.lang System loadLibrary

Introduction

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

Prototype

@CallerSensitive
public static void loadLibrary(String libname) 

Source Link

Document

Loads the native library specified by the libname argument.

Usage

From source file:Questao3.java

void desvioPadrao() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    /**/*  w  w w  .  j a va 2s.  c  o m*/
     * Array temporario que ir armazenar os valores de um pixel
     * para todas as imagens de entrada.
     */
    double[] tmp = new double[arquivos.length];

    /**
     * Tranforma imagens em matrizes em escala de cinza
     */
    for (String s : arquivos) {
        images.add(Imgcodecs.imread(s, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE));
    }

    /**
     * Matriz que ir armazenar os valores de desvio padro
     */
    double[][] stdDev = new double[images.get(0).rows()][images.get(0).cols()];

    /**
     * Calculo do desvio padro para cada pixel de todas as imagens.
     */
    for (int i = 0; i < images.get(0).rows(); i++) {
        for (int j = 0; j < images.get(0).cols(); j++) {
            for (int k = 0; k < arquivos.length; k++) {
                tmp[k] = images.get(k).get(i, j)[0];
            }
            double tmpDev = Math.sqrt(somatorio(tmp) / arquivos.length);
            stdDev[i][j] = tmpDev;

        }
    }

    /**
     * Cria uma matriz opencv do tipo escala de cinza
     */
    ruido = new Mat(new Size((int) images.get(0).cols(), (int) images.get(0).rows()), CvType.CV_8UC1);
    /**
     * Matriz que ira receber a matriz de desvio padro normalizada
     * Maior rudo = 255
     * Ausncia de rudo = 0
     */
    double[][] d = normalizacao(stdDev);
    /**
     * Salva o resultado na imagem ruido.jpg
     */
    Imgcodecs.imwrite("ruido.jpg", ruido);
    showResult("ruido.jpg");
}

From source file:org.apache.camel.component.zeromq.ZeroMQComponent.java

public ZeroMQComponent() {
    LOG.trace("Begin ZeroMQComponent.ZeroMQComponent");
    try {/*from  ww  w  .  j av a  2  s .com*/
        try {
            NativeLibraryLoader.loadLibrary(LIBNAME);
        } catch (java.io.IOException e) {
            System.loadLibrary(LIBNAME);
        }
    } catch (Exception ex) {
        LOG.fatal(ex, ex);
    } finally {
        LOG.trace("End ZeroMQComponent.ZeroMQComponent");
    }
}

From source file:org.cryptomator.jni.JniModule.java

@Provides
@Singleton/*from  www  . j  a v  a2s. c  o m*/
public Optional<WinFunctions> winFunctions(Lazy<WinFunctions> winFunction) {
    if (SystemUtils.IS_OS_WINDOWS) {
        try {
            System.loadLibrary(WinFunctions.LIB_NAME);
            LOG.info("loaded {}", System.mapLibraryName(WinFunctions.LIB_NAME));
            return Optional.of(winFunction.get());
        } catch (UnsatisfiedLinkError e) {
            e.printStackTrace();
            LOG.error("Could not load JNI lib {} from path {}", System.mapLibraryName(WinFunctions.LIB_NAME),
                    System.getProperty("java.library.path"));
        }
    }
    return Optional.empty();
}

From source file:glluch.com.ontotaxoseeker.FreelingTagger.java

/**
 * Analizes a doc and return only the terms that are nouns.
 * @param doc The text to be analized./*from   www  .  j  a v a2s  .c om*/
 * @return Terms, all the nouns terms in doc.
 * @throws IOException Reading files.
 */
public static Terms nouns(String doc) throws IOException {
    if (StringUtils.isEmpty(doc)) {
        Out.p("FreelingTagger, nouns: doc is null");
        //throw new IllegalArgumentException("The argument cannot be null");
        Terms ts = new Terms();
        return ts;
    }
    System.loadLibrary("freeling_javaAPI");

    Util.initLocale("default");

    // Create options set for maco analyzer.
    // Default values are Ok, except for data files.
    if (null == op) {
        op = new MacoOptions(LANG);

        op.setDataFiles("", DATA + "common/punct.dat", DATA + LANG + "/dicc.src", DATA + LANG + "/afixos.dat",
                "", "resources/testLocucionsEn.dat", DATA + LANG + "/np.dat", DATA + LANG + "/quantities.dat",
                DATA + LANG + "/probabilitats.dat");
    }

    if (tk == null) {
        tk = new Tokenizer(DATA + LANG + "/tokenizer.dat");
    }
    if (sp == null)
        sp = new Splitter(DATA + LANG + "/splitter.dat");
    SWIGTYPE_p_splitter_status sid = sp.openSession();

    Maco mf = new Maco(op);
    mf.setActiveOptions(false, true, true, true, // select which among created 
            true, true, false, true, // submodules are to be used. 
            true, true, true, true); // default: all created submodules 
                                     // are used

    if (tg == null)
        tg = new HmmTagger(DATA + LANG + "/tagger.dat", true, 2);
    if (parser == null)
        parser = new ChartParser(DATA + LANG + "/chunker/grammar-chunk.dat");
    if (dep == null)
        dep = new DepTxala(DATA + LANG + "/dep_txala/dependences.dat", parser.getStartSymbol());
    if (neclass == null)
        neclass = new Nec(DATA + LANG + "/nerc/nec/nec-ab-poor1.dat");

    if (sen == null)
        sen = new Senses(DATA + LANG + "/senses.dat"); // sense dictionary
    if (dis == null)
        dis = new Ukb(DATA + LANG + "/ukb.dat"); // sense disambiguator

    // Extract the tokens from the line of text.
    ListWord l = tk.tokenize(doc);

    // Split the tokens into distinct sentences.
    ListSentence ls = sp.split(sid, l, false);

    // Perform morphological analysis
    mf.analyze(ls);

    // Perform part-of-speech tagging.
    tg.analyze(ls);

    // Perform named entity (NE) classificiation.
    neclass.analyze(ls);

    //sen.analyze( ls );
    //dis.analyze( ls );
    Terms tagOnlyNouns = FreelingTagger.tagOnlyNouns(ls);
    //debug("DOC");
    //debug(doc);
    //debug("Result");
    //debug(tagOnlyNouns.pretyPrint());
    return tagOnlyNouns;

}

From source file:org.geotools.process.idl.IDLProcessFactory.java

/**
 * Load IDL Lib to check everything needed to support IDL processes, is on its place. 
 *//*from  w w  w .j a v a2s  .  c  o  m*/
private synchronized static void loadIDL() {
    if (init == false)
        init = true;
    else
        return;
    try {
        // Try loading a required IDL libraries
        System.loadLibrary("idl_ebutil");
        isIDLAvailable = true;
    } catch (UnsatisfiedLinkError e) {
        LOGGER.warning("Unable to load IDL DLLs");
        isIDLAvailable = false;
    }
}

From source file:org.apache.camel.component.zeromq.ZeroMQComponent.java

public ZeroMQComponent(CamelContext context) {
    super(context);
    LOG.trace("Begin ZeroMQComponent.ZeroMQComponent");
    try {/*www  .ja v  a  2  s . c o m*/
        try {
            NativeLibraryLoader.loadLibrary(LIBNAME);
        } catch (java.io.IOException e) {
            System.loadLibrary(LIBNAME);
        }
    } catch (Exception ex) {
        LOG.fatal(ex, ex);
    } finally {
        LOG.trace("End ZeroMQComponent.ZeroMQComponent");
    }
}

From source file:edu.isi.mtandao.handle.IndriHandler.java

public IndriHandler() {
    super();/*  w  w  w .  j a v  a2s .  c  o m*/

    // initialize indri jni library
    System.loadLibrary(LIB_NAME);

    // get a new indri index environment
    mIndex = new IndexEnvironment();

    // get an indri query environment
    mQuery = new QueryEnvironment();
}

From source file:Main.java

/**
 * Load the libtango_client_api.so library based on different Tango device setup.
 *
 * @return returns the loaded architecture id.
 *//* w w w . j av  a  2s  .  com*/
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:com.tencent.mars.sample.SampleApplicaton.java

@Override
public void onCreate() {
    super.onCreate();
    context = this;

    System.loadLibrary("stlport_shared");
    System.loadLibrary("marsxlog");
    openXlog();/*from   ww  w  .j  a v a 2s  .  c om*/

    MarsServiceNative.setProfileFactory(new MarsServiceProfileFactory() {
        @Override
        public MarsServiceProfile createMarsServiceProfile() {
            return new SampleMarsServiceProfile();
        }
    });

    // NOTE: MarsServiceProxy is for client/caller
    // Initialize MarsServiceProxy for local client, can be moved to other place
    MarsServiceProxy.init(this, getMainLooper(), null);
    MarsServiceProxy.inst.accountInfo = accountInfo;

    // Auto bind all activity event
    ActivityEvent.bind(getApplicationContext());

    Log.i(TAG, "application started");
}

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  ww  .  ja  v  a2s  .  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;
}