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:uk.co.armedpineapple.cth.SDLActivity.java

void loadApplication() {

    // Load the libraries
    System.loadLibrary("SDL");
    System.loadLibrary("luajit");
    System.loadLibrary("SDL_mixer");
    System.loadLibrary("ffmpeg");
    System.loadLibrary("appmain");

    try {//from w  ww  . j  a  va 2s . c o  m
        app.configuration.writeToFile();
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(LOG_TAG, "Couldn't write to configuration file");
        BugSenseHandler.sendException(e);
    }

    File f = new File(app.configuration.getSaveGamesPath());

    if (!f.isDirectory()) {
        f.mkdirs();
    }

    // So we can call stuff from static callbacks
    mSingleton = this;

    hideSystemUi();

    mSurface = new SDLSurface(this, app.configuration.getDisplayWidth(), app.configuration.getDisplayHeight());
    mSurface.setZOrderOnTop(false);

    DrawerLayout mainLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.game, null);
    FrameLayout gameFrame = ((FrameLayout) mainLayout.findViewById(R.id.game_frame));

    gameFrame.addView(mSurface);
    setContentView(mainLayout);

    mHapticLauncher = new Launcher(this);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.main_layout);
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    mDrawerList.setAdapter(new NavDrawerAdapter(this,
            uk.co.armedpineapple.cth.MenuItems.getItems(BuildConfig.DEBUG || app.configuration.getDebug())));
    mDrawerList.setOnItemClickListener(new NavDrawerListListener(this));
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    mDrawerLayout.setDrawerListener(new DrawerListener() {

        @Override
        public void onDrawerClosed(View arg0) {
            // Restore game speed
            cthGameSpeed(app.configuration.getGameSpeed());
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }

        @Override
        public void onDrawerOpened(View arg0) {
            // Pause the game
            cthGameSpeed(0);
        }

        @Override
        public void onDrawerSlide(View arg0, float arg1) {
            arg0.bringToFront();
            mDrawerLayout.bringChildToFront(arg0);
            mDrawerLayout.requestLayout();

        }

        @Override
        public void onDrawerStateChanged(int arg0) {
            // TODO Auto-generated method stub

        }

    });
    SurfaceHolder holder = mSurface.getHolder();
    holder.setFixedSize(app.configuration.getDisplayWidth(), app.configuration.getDisplayHeight());

    gameFrame.setVisibility(View.VISIBLE);

    hasGameLoaded = true;

}

From source file:org.energy_home.jemma.internal.device.zgd.StreamGobbler.java

/**
 * We try to load a dll that causes an UnsatisfiedLinkError exception. This
 * exception contains in the error message the location of the native
 * storage area. We exctract the path and return back to the caller. FIXME:
 * probably this trick is valid only on the Sun's jdk.
 * //from  w w  w  . j  a va 2 s  .co m
 * @param filename
 * @return
 */

private String getNativeStorageLocation(String filename) {
    String path = "";

    if (logDebug && (log != null))
        log.debug("getNativeStorageLocation = " + filename);

    try {
        System.loadLibrary(filename);
    } catch (UnsatisfiedLinkError e) {
        int index_start = 0;
        int index_end = 0;

        if (e.getMessage().indexOf("cannot dynamically load executable") > 0) {
            index_end = e.getMessage().indexOf("(", index_start + 2);
            if (index_end == -1) {
                // try with :
                index_end = e.getMessage().indexOf(":", index_start + 2);
            }
        } else {
            index_end = e.getMessage().indexOf(":", index_start + 2) + 1;
        }

        path = e.getMessage().substring(index_start, index_end - filename.length() - 1);
    } catch (Exception e) {
        log.error(e);
        return path;
    }
    return path + File.separator;
}

From source file:org.ow2.proactive.resourcemanager.utils.RMNodeStarter.java

private void loadSigarIfRunningWithOneJar() {
    if (OneJar.isRunningWithOneJar()) {
        String nativeLibraryName = SigarLoader.getNativeLibraryName();
        String nativeLibraryNameToLoad = nativeLibraryName.replace(SigarLoader.getLibraryExtension(), "")
                .replace(SigarLoader.getLibraryPrefix(), "");
        System.loadLibrary(nativeLibraryNameToLoad);
    }//from  ww w.ja v  a2 s. com
}

From source file:cpsd.ImageGUI.java

private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    // System.load("/usr/local/share/OpenCV/java/libopencv_java249.so");
    fileChooser.setCurrentDirectory(new File("E:\\"));
    int returnVal = fileChooser.showOpenDialog(this);

    int i = 0;/*from ww  w  . j a v a  2s.  c o  m*/
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fileChooser.getSelectedFile();
        FileFilter filter = new FileNameExtensionFilter("JPEG File",
                new String[] { "jpg", "jpeg", "tif", "gif" });
        try {
            // IplImage img = cvLoadImage(file.getAbsolutePath());
            ImageIcon ii = new ImageIcon(file.getAbsolutePath());
            path.setText(file.getAbsolutePath());
            originalPane.setViewportView(new JLabel(ii));
            //image = ImageClass.getInstance();
            ImageClass.getInstance().setImage(Highgui.imread(path.getText()));
            rgb2Gray();
            listModel = new DefaultListModel();
        } catch (Exception ex) {
            System.out.println("problem accessing file" + file.getAbsolutePath());
        }
    } else {
        System.out.println("File access cancelled by user."); // TODO add your handling code here:
    } //GEN-LAST:event_browseActionPerformed
}

From source file:com.android.wfds.printservice.WPrintService.java

private static synchronized void loadLibraries(ApplicationInfo appInfo) {
    if (!mLibrariesLoaded) {
        if (((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0)
                || ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)) {
            System.loadLibrary("wfdscrypto");
            System.loadLibrary("wfdsssl");
            System.loadLibrary("wfdsjpeg");
            System.loadLibrary("wfdspng");
            System.loadLibrary("wfdscups");
            System.loadLibrary("wfds");
        } else {/*  w  ww  .  ja  va  2s  .com*/
            System.load(Environment.getRootDirectory() + "/lib/libwfdscrypto.so");
            System.load(Environment.getRootDirectory() + "/lib/libwfdsssl.so");
            System.load(Environment.getRootDirectory() + "/lib/libwfdsjpeg.so");
            System.load(Environment.getRootDirectory() + "/lib/libwfdspng.so");
            System.load(Environment.getRootDirectory() + "/lib/libwfdscups.so");
            System.load(Environment.getRootDirectory() + "/lib/libwfds.so");
        }
        mLibrariesLoaded = true;
    }
}

From source file:io.smartspaces.launcher.bootstrap.SmartSpacesFrameworkBootstrap.java

/**
 * Load a collection of libraries.// w  w  w  .  j  a v  a 2s . c  o  m
 *
 * @param libraries
 *          the libraries to load
 */
private void loadLibraries(List<String> libraries) {
    for (String library : libraries) {
        loggingProvider.getLog().debug(String.format("Loading system library %s", library));
        System.loadLibrary(library);
    }
}

From source file:cpsd.ImageGUI.java

private void enhanceContrast() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    //System.load("/usr/local/share/OpenCV/java/libopencv_java249.so");
    // rgb2Gray();
    Mat source = ImageClass.getInstance().getImage();
    Mat destination = new Mat(source.rows(), source.cols(), source.type());
    Imgproc.equalizeHist(source, destination);
    image.getInstance().setImage(destination);
}

From source file:cpsd.ImageGUI.java

private void enhanceSharpness(double alpha) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    // System.load("/usr/local/share/OpenCV/java/libopencv_java249.so");
    Mat source = ImageClass.getInstance().getImage();
    Mat destination = new Mat(source.rows(), source.cols(), source.type());
    /// GaussianBlur(Mat src, Mat dst, Size ksize, double sigmaX);
    Imgproc.GaussianBlur(source, destination, new org.opencv.core.Size(0, 0), 10);
    ///addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst);
    Core.addWeighted(source, alpha, destination, -0.5, 0, destination);
    ImageClass.getInstance().setImage(destination);
    sharpSlider.setValue((int) (alpha * 10));
}

From source file:cpsd.ImageGUI.java

private void transform(final int[][] arr) {
    try {/*from  ww w .  j  a v  a2  s  . c om*/
        int kernelSize = 3;
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //System.load("/usr/local/share/OpenCV/java/libopencv_java249.so");
        // System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
        Mat source = ImageClass.getInstance().getImage();
        Mat destination = new Mat(source.rows(), source.cols(), source.type());

        Mat kernel = new Mat(kernelSize, kernelSize, CvType.CV_32F) {
            {
                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                        System.out.println(arr[i][j]);
                        put(i, j, arr[i][j]);
                    }
                }
            }
        };
        Imgproc.filter2D(source, destination, -1, kernel);
        ImageClass.getInstance().setImage(destination);
    } catch (Exception e) {
        System.out.println("Error: " + e.getMessage());
    }
}

From source file:org.mozilla.gecko.GeckoApp.java

/** Called when the activity is first created. */
@Override//ww w.jav a 2s . c  o m
public void onCreate(Bundle savedInstanceState) {
    mAppContext = this;

    // StrictMode is set by defaults resource flag |enableStrictMode|.
    if (getResources().getBoolean(R.bool.enableStrictMode)) {
        enableStrictMode();
    }

    System.loadLibrary("mozglue");
    mMainHandler = new GeckoAppHandler();
    Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
    if (savedInstanceState != null) {
        mLastTitle = savedInstanceState.getString(SAVED_STATE_TITLE);
        mLastViewport = savedInstanceState.getString(SAVED_STATE_VIEWPORT);
        mLastScreen = savedInstanceState.getByteArray(SAVED_STATE_SCREEN);
        mRestoreSession = savedInstanceState.getBoolean(SAVED_STATE_SESSION);
    }

    super.onCreate(savedInstanceState);

    mOrientation = getResources().getConfiguration().orientation;

    setContentView(R.layout.gecko_app);

    if (Build.VERSION.SDK_INT >= 11) {
        mBrowserToolbar = (BrowserToolbar) GeckoActionBar.getCustomView(this);
    } else {
        mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
    }

    // setup gecko layout
    mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
    mMainLayout = (LinearLayout) findViewById(R.id.main_layout);

    mConnectivityFilter = new IntentFilter();
    mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mConnectivityReceiver = new GeckoConnectivityReceiver();
}