Java Library Load loadSystemLibrary(String filename)

Here you can find the source of loadSystemLibrary(String filename)

Description

Load the JNI library from the folder specified by java.library.path

License

Apache License

Parameter

Parameter Description
libName a parameter

Declaration

public static boolean loadSystemLibrary(String filename) 

Method Source Code

//package com.java2s;
/*/*from w w  w . jav a 2s . co m*/
 *  Copyright 2014 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

import java.io.File;

public class Main {
    /**
     * Load the JNI library from the folder specified by java.library.path
     * 
     * @param libName
     */
    public static boolean loadSystemLibrary(String filename) {
        try {
            System.loadLibrary(filename);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * Load the JNI library directly by using the file name
     * 
     * @param filename
     * @param targetLibFolder
     */
    public static boolean loadLibrary(String filename, String targetLibFolder) {
        try {
            System.load(targetLibFolder + File.separator + filename);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

  1. loadLibrary(String filename, String targetLibFolder)
  2. loadSystemLibrary(String library)