Example usage for java.lang UnsatisfiedLinkError printStackTrace

List of usage examples for java.lang UnsatisfiedLinkError printStackTrace

Introduction

In this page you can find the example usage for java.lang UnsatisfiedLinkError printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.lfv.lanzius.Main.java

public static void main(String[] args) {

    /*/*from  w w  w.j  ava 2 s  .  c om*/
     * debug levels:
     * error - Runtime errors or unexpected conditions. Expect these to be immediately visible on a status console. See also Internationalization.
     * warn  - Use of deprecated APIs, poor use of API, 'almost' errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Expect these to be immediately visible on a status console. See also Internationalization.
     * info  - Interesting runtime events (startup/shutdown). Expect these to be immediately visible on a console, so be conservative and keep to a minimum. See also Internationalization.
     * debug - detailed information on the flow through the system. Expect these to be written to logs only.
     */

    Log log = null;
    DOMConfigurator conf = new DOMConfigurator();
    DOMConfigurator.configure("data/properties/loggingproperties.xml");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

    try {
        if (args.length >= 1) {
            // Help
            if (args[0].startsWith("-h")) {
                printUsage();
                return;
            }
            // List devices
            else if (args[0].startsWith("-l")) {
                AudioTest.listDevices();
                return;
            }
            // Test seleted device
            else if (args[0].startsWith("-d")) {
                System.setProperty("org.apache.commons.logging.Log",
                        "org.apache.commons.logging.impl.SimpleLog");
                System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "warn");
                try {
                    String option = "all";
                    if (args.length >= 4)
                        option = args[3];

                    if (option.equals("loop:direct"))
                        AudioTest.testDevicesDirect(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
                    else {
                        if (option.indexOf("debug") != -1)
                            System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");

                        AudioTest.testDevices(Integer.parseInt(args[1]), Integer.parseInt(args[2]), option,
                                (args.length >= 5) ? args[4] : null, (args.length >= 6) ? args[5] : null,
                                (args.length >= 7) ? args[6] : null);
                    }
                } catch (Exception ex) {
                    System.out.println();
                    System.out.println(Config.VERSION);
                    System.out.println();
                    System.out.println("Usage:");
                    System.out.println(
                            "  yada.jar -d output_device input_device <option> <jitter_buffer> <output_buffer> <input_buffer>");
                    System.out.println("  option:");
                    System.out.println("    all(default)");
                    System.out.println("    clip");
                    System.out.println("    loop:jspeex");
                    System.out.println("    loop:null");
                    System.out.println("    loop:direct");
                    System.out.println("    loopdebug:jspeex");
                    System.out.println("    loopdebug:null");
                    System.out.println("  jitter_buffer:");
                    System.out.println("    size of jitter buffer in packets (1-20)");
                    System.out.println("  output_buffer:");
                    System.out.println("    size of output buffer in packets (1.0-4.0)");
                    System.out.println("  input_buffer:");
                    System.out.println("    size of input buffer in packets (1.0-4.0)");
                    System.out.println();
                    if (AudioTest.showStackTrace && !(ex instanceof ArrayIndexOutOfBoundsException))
                        ex.printStackTrace();
                }
                //System.out.println("Exiting...");
                return;
            } else if (args[0].startsWith("-m")) {
                System.setProperty("org.apache.commons.logging.Log",
                        "org.apache.commons.logging.impl.SimpleLog");
                System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "warn");
                try {
                    AudioTest.testMicrophoneLevel(Integer.parseInt(args[1]));
                } catch (Exception ex) {
                    System.out.println();
                    System.out.println(Config.VERSION);
                    System.out.println();
                    System.out.println("Usage:");
                    System.out.println("  yada.jar -m input_device");
                    System.out.println();
                    if (AudioTest.showStackTrace && !(ex instanceof ArrayIndexOutOfBoundsException))
                        ex.printStackTrace();
                }
                return;
            } else if (args[0].startsWith("-s")) {
                Packet.randomSeed = 9182736455L ^ System.currentTimeMillis();
                if (args.length > 2 && args[1].startsWith("-configuration")) {
                    String configFilename = args[2];
                    if (args.length > 4 && args[3].startsWith("-exercise")) {
                        String exerciseFilename = args[4];

                        LanziusServer.start(configFilename, exerciseFilename);
                    } else {
                        LanziusServer.start(configFilename);
                    }
                } else {
                    LanziusServer.start();
                }
                return;
            } else if (args[0].startsWith("-f")) {
                System.setProperty("org.apache.commons.logging.Log",
                        "org.apache.commons.logging.impl.SimpleLog");
                System.setProperty(
                        "org.apache.commons.logging.simplelog.log.com.lfv.lanzius.application.FootSwitchController",
                        "debug");
                try {
                    System.out.println("Starting footswitch controller test using device " + args[1]);
                    try {
                        boolean inverted = false;
                        if (args.length >= 3)
                            inverted = args[2].toLowerCase().startsWith("inv");
                        FootSwitchController c = new FootSwitchController(null, args[1],
                                Constants.PERIOD_FTSW_CONNECTED, inverted);
                        c.start();
                        Thread.sleep(30000);
                    } catch (UnsatisfiedLinkError err) {
                        if (args.length > 1)
                            System.out.println("UnsatisfiedLinkError: " + err.getMessage());
                        else
                            throw new ArrayIndexOutOfBoundsException();
                        System.out.println("Missing ftsw library (ftsw.dll or libftsw.so)");
                        if (!args[1].equalsIgnoreCase("ftdi"))
                            System.out
                                    .println("Missing rxtxSerial library (rxtxSerial.dll or librxtxSerial.so)");
                        if (AudioTest.showStackTrace)
                            err.printStackTrace();
                    }
                } catch (Exception ex) {
                    if (ex instanceof NoSuchPortException)
                        System.out.println("The serial port " + args[1] + " does not exist!");
                    else if (ex instanceof PortInUseException)
                        System.out.println("The serial port " + args[1] + " is already in use!");
                    System.out.println();
                    System.out.println(Config.VERSION);
                    System.out.println();
                    System.out.println("Usage:");
                    System.out.println("  yada.jar -f interface <invert>");
                    System.out.println("  interface:");
                    System.out.println("    ftdi");
                    System.out.println("    comport (COMx or /dev/ttyx)");
                    System.out.println("  invert:");
                    System.out.println("    true");
                    System.out.println("    false (default)");
                    System.out.println();
                    if (AudioTest.showStackTrace && !(ex instanceof ArrayIndexOutOfBoundsException))
                        ex.printStackTrace();
                }
                return;
            } else if (args[0].startsWith("-c")) {
                Packet.randomSeed = 7233103157L ^ System.currentTimeMillis();
                if (args.length >= 2) {
                    try {
                        int id = Integer.valueOf(args[1]);
                        if (id <= 0)
                            throw new NumberFormatException();
                        Controller c = Controller.getInstance();
                        if (args.length >= 3) {
                            if (args[2].equalsIgnoreCase("test")) {
                                c.setAutoTester(true);
                            }
                        }
                        c.init(id);
                        return;
                    } catch (NumberFormatException ex) {
                        printUsage();
                    }
                } else {
                    Controller.getInstance().init(0);
                }
            } else
                printUsage();
        } else
            printUsage();
    } catch (Throwable t) {
        if (log == null)
            log = LogFactory.getLog(Main.class);
        log.error("Unhandled exception or error", t);
    }
}

From source file:com.jug.MoMA.java

/**
 * PROJECT MAIN/* w  ww.  j  a va  2s  . c  o  m*/
 *
 * @param args
 */
public static void main(final String[] args) {
    if (showIJ)
        new ImageJ();

    //      // ===== set look and feel ========================================================================
    //      try {
    //         // Set cross-platform Java L&F (also called "Metal")
    //         UIManager.setLookAndFeel(
    //               UIManager.getCrossPlatformLookAndFeelClassName() );
    //      } catch ( final UnsupportedLookAndFeelException e ) {
    //         // handle exception
    //      } catch ( final ClassNotFoundException e ) {
    //         // handle exception
    //      } catch ( final InstantiationException e ) {
    //         // handle exception
    //      } catch ( final IllegalAccessException e ) {
    //         // handle exception
    //      }

    // ===== command line parsing ======================================================================

    // create Options object & the parser
    final Options options = new Options();
    final CommandLineParser parser = new BasicParser();
    // defining command line options
    final Option help = new Option("help", "print this message");

    final Option headless = new Option("h", "headless", false,
            "start without user interface (note: input-folder must be given!)");
    headless.setRequired(false);

    final Option timeFirst = new Option("tmin", "min_time", true, "first time-point to be processed");
    timeFirst.setRequired(false);

    final Option timeLast = new Option("tmax", "max_time", true, "last time-point to be processed");
    timeLast.setRequired(false);

    final Option optRange = new Option("orange", "opt_range", true, "initial optimization range");
    optRange.setRequired(false);

    final Option numChannelsOption = new Option("c", "channels", true,
            "number of channels to be loaded and analyzed.");
    numChannelsOption.setRequired(true);

    final Option minChannelIdxOption = new Option("cmin", "min_channel", true,
            "the smallest channel index (usually 0 or 1, default is 1).");
    minChannelIdxOption.setRequired(false);

    final Option infolder = new Option("i", "infolder", true, "folder to read data from");
    infolder.setRequired(false);

    final Option outfolder = new Option("o", "outfolder", true,
            "folder to write preprocessed data to (equals infolder if not given)");
    outfolder.setRequired(false);

    final Option userProps = new Option("p", "props", true, "properties file to be loaded (mm.properties)");
    userProps.setRequired(false);

    options.addOption(help);
    options.addOption(headless);
    options.addOption(numChannelsOption);
    options.addOption(minChannelIdxOption);
    options.addOption(timeFirst);
    options.addOption(timeLast);
    options.addOption(optRange);
    options.addOption(infolder);
    options.addOption(outfolder);
    options.addOption(userProps);
    // get the commands parsed
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (final ParseException e1) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(
                "... [-p props-file] -i in-folder [-o out-folder] -c <num-channels> [-cmin start-channel-ids] [-tmin idx] [-tmax idx] [-orange num-frames] [-headless]",
                "", options, "Error: " + e1.getMessage());
        System.exit(0);
    }

    if (cmd.hasOption("help")) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("... -i <in-folder> -o [out-folder] [-headless]", options);
        System.exit(0);
    }

    if (cmd.hasOption("h")) {
        System.out.println(">>> Starting MM in headless mode.");
        HEADLESS = true;
        if (!cmd.hasOption("i")) {
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Headless-mode requires option '-i <in-folder>'...", options);
            System.exit(0);
        }
    }

    File inputFolder = null;
    if (cmd.hasOption("i")) {
        inputFolder = new File(cmd.getOptionValue("i"));

        if (!inputFolder.isDirectory()) {
            System.out.println("Error: Input folder is not a directory!");
            System.exit(2);
        }
        if (!inputFolder.canRead()) {
            System.out.println("Error: Input folder cannot be read!");
            System.exit(2);
        }
    }

    File outputFolder = null;
    if (!cmd.hasOption("o")) {
        if (inputFolder == null) {
            System.out.println(
                    "Error: Output folder would be set to a 'null' input folder! Please check your command line arguments...");
            System.exit(3);
        }
        outputFolder = inputFolder;
        STATS_OUTPUT_PATH = outputFolder.getAbsolutePath();
    } else {
        outputFolder = new File(cmd.getOptionValue("o"));

        if (!outputFolder.isDirectory()) {
            System.out.println("Error: Output folder is not a directory!");
            System.exit(3);
        }
        if (!inputFolder.canWrite()) {
            System.out.println("Error: Output folder cannot be written to!");
            System.exit(3);
        }

        STATS_OUTPUT_PATH = outputFolder.getAbsolutePath();
    }

    fileUserProps = null;
    if (cmd.hasOption("p")) {
        fileUserProps = new File(cmd.getOptionValue("p"));
    }

    if (cmd.hasOption("cmin")) {
        minChannelIdx = Integer.parseInt(cmd.getOptionValue("cmin"));
    }
    if (cmd.hasOption("c")) {
        numChannels = Integer.parseInt(cmd.getOptionValue("c"));
    }

    if (cmd.hasOption("tmin")) {
        minTime = Integer.parseInt(cmd.getOptionValue("tmin"));
    }
    if (cmd.hasOption("tmax")) {
        maxTime = Integer.parseInt(cmd.getOptionValue("tmax"));
    }

    if (cmd.hasOption("orange")) {
        initOptRange = Integer.parseInt(cmd.getOptionValue("orange"));
    }

    // ******** CHECK GUROBI ********* CHECK GUROBI ********* CHECK GUROBI *********
    final String jlp = System.getProperty("java.library.path");
    //      System.out.println( jlp );
    try {
        new GRBEnv("MoMA_gurobi.log");
    } catch (final GRBException e) {
        final String msgs = "Initial Gurobi test threw exception... check your Gruobi setup!\n\nJava library path: "
                + jlp;
        if (HEADLESS) {
            System.out.println(msgs);
        } else {
            JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE);
        }
        e.printStackTrace();
        System.exit(98);
    } catch (final UnsatisfiedLinkError ulr) {
        final String msgs = "Could initialize Gurobi.\n"
                + "You might not have installed Gurobi properly or you miss a valid license.\n"
                + "Please visit 'www.gurobi.com' for further information.\n\n" + ulr.getMessage()
                + "\nJava library path: " + jlp;
        if (HEADLESS) {
            System.out.println(msgs);
        } else {
            JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE);
            ulr.printStackTrace();
        }
        System.out.println("\n>>>>> Java library path: " + jlp + "\n");
        System.exit(99);
    }
    // ******* END CHECK GUROBI **** END CHECK GUROBI **** END CHECK GUROBI ********

    final MoMA main = new MoMA();
    if (!HEADLESS) {
        guiFrame = new JFrame();
        main.initMainWindow(guiFrame);
    }

    System.out.println("VERSION: " + VERSION_STRING);

    props = main.loadParams();
    BGREM_TEMPLATE_XMIN = Integer
            .parseInt(props.getProperty("BGREM_TEMPLATE_XMIN", Integer.toString(BGREM_TEMPLATE_XMIN)));
    BGREM_TEMPLATE_XMAX = Integer
            .parseInt(props.getProperty("BGREM_TEMPLATE_XMAX", Integer.toString(BGREM_TEMPLATE_XMAX)));
    BGREM_X_OFFSET = Integer.parseInt(props.getProperty("BGREM_X_OFFSET", Integer.toString(BGREM_X_OFFSET)));
    GL_WIDTH_IN_PIXELS = Integer
            .parseInt(props.getProperty("GL_WIDTH_IN_PIXELS", Integer.toString(GL_WIDTH_IN_PIXELS)));
    MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS = Integer.parseInt(props.getProperty(
            "MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS", Integer.toString(MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS)));
    GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS = Integer
            .parseInt(props.getProperty("GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS",
                    Integer.toString(GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS)));
    GL_OFFSET_BOTTOM = Integer
            .parseInt(props.getProperty("GL_OFFSET_BOTTOM", Integer.toString(GL_OFFSET_BOTTOM)));
    if (GL_OFFSET_BOTTOM == -1) {
        GL_OFFSET_BOTTOM_AUTODETECT = true;
    } else {
        GL_OFFSET_BOTTOM_AUTODETECT = false;
    }
    GL_OFFSET_TOP = Integer.parseInt(props.getProperty("GL_OFFSET_TOP", Integer.toString(GL_OFFSET_TOP)));
    GL_OFFSET_LATERAL = Integer
            .parseInt(props.getProperty("GL_OFFSET_LATERAL", Integer.toString(GL_OFFSET_LATERAL)));
    MIN_CELL_LENGTH = Integer.parseInt(props.getProperty("MIN_CELL_LENGTH", Integer.toString(MIN_CELL_LENGTH)));
    MIN_GAP_CONTRAST = Float
            .parseFloat(props.getProperty("MIN_GAP_CONTRAST", Float.toString(MIN_GAP_CONTRAST)));
    SIGMA_PRE_SEGMENTATION_X = Float.parseFloat(
            props.getProperty("SIGMA_PRE_SEGMENTATION_X", Float.toString(SIGMA_PRE_SEGMENTATION_X)));
    SIGMA_PRE_SEGMENTATION_Y = Float.parseFloat(
            props.getProperty("SIGMA_PRE_SEGMENTATION_Y", Float.toString(SIGMA_PRE_SEGMENTATION_Y)));
    SIGMA_GL_DETECTION_X = Float
            .parseFloat(props.getProperty("SIGMA_GL_DETECTION_X", Float.toString(SIGMA_GL_DETECTION_X)));
    SIGMA_GL_DETECTION_Y = Float
            .parseFloat(props.getProperty("SIGMA_GL_DETECTION_Y", Float.toString(SIGMA_GL_DETECTION_Y)));
    SEGMENTATION_MIX_CT_INTO_PMFRF = Float.parseFloat(props.getProperty("SEGMENTATION_MIX_CT_INTO_PMFRF",
            Float.toString(SEGMENTATION_MIX_CT_INTO_PMFRF)));
    SEGMENTATION_CLASSIFIER_MODEL_FILE = props.getProperty("SEGMENTATION_CLASSIFIER_MODEL_FILE",
            SEGMENTATION_CLASSIFIER_MODEL_FILE);
    CELLSIZE_CLASSIFIER_MODEL_FILE = props.getProperty("CELLSIZE_CLASSIFIER_MODEL_FILE",
            CELLSIZE_CLASSIFIER_MODEL_FILE);
    DEFAULT_PATH = props.getProperty("DEFAULT_PATH", DEFAULT_PATH);

    GUROBI_TIME_LIMIT = Double
            .parseDouble(props.getProperty("GUROBI_TIME_LIMIT", Double.toString(GUROBI_TIME_LIMIT)));
    GUROBI_MAX_OPTIMALITY_GAP = Double.parseDouble(
            props.getProperty("GUROBI_MAX_OPTIMALITY_GAP", Double.toString(GUROBI_MAX_OPTIMALITY_GAP)));

    GUI_POS_X = Integer.parseInt(props.getProperty("GUI_POS_X", Integer.toString(DEFAULT_GUI_POS_X)));
    GUI_POS_Y = Integer.parseInt(props.getProperty("GUI_POS_Y", Integer.toString(DEFAULT_GUI_POS_X)));
    GUI_WIDTH = Integer.parseInt(props.getProperty("GUI_WIDTH", Integer.toString(GUI_WIDTH)));
    GUI_HEIGHT = Integer.parseInt(props.getProperty("GUI_HEIGHT", Integer.toString(GUI_HEIGHT)));
    GUI_CONSOLE_WIDTH = Integer
            .parseInt(props.getProperty("GUI_CONSOLE_WIDTH", Integer.toString(GUI_CONSOLE_WIDTH)));

    if (!HEADLESS) {
        // Iterate over all currently attached monitors and check if sceen
        // position is actually possible,
        // otherwise fall back to the DEFAULT values and ignore the ones
        // coming from the properties-file.
        boolean pos_ok = false;
        final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice[] gs = ge.getScreenDevices();
        for (int i = 0; i < gs.length; i++) {
            if (gs[i].getDefaultConfiguration().getBounds()
                    .contains(new java.awt.Point(GUI_POS_X, GUI_POS_Y))) {
                pos_ok = true;
            }
        }
        // None of the screens contained the top-left window coordinates -->
        // fall back onto default values...
        if (!pos_ok) {
            GUI_POS_X = DEFAULT_GUI_POS_X;
            GUI_POS_Y = DEFAULT_GUI_POS_Y;
        }
    }

    String path = props.getProperty("import_path", System.getProperty("user.home"));
    if (inputFolder == null || inputFolder.equals("")) {
        inputFolder = main.showStartupDialog(guiFrame, path);
    }
    System.out.println("Default filename decoration = " + inputFolder.getName());
    defaultFilenameDecoration = inputFolder.getName();
    path = inputFolder.getAbsolutePath();
    props.setProperty("import_path", path);

    GrowthLineSegmentationMagic.setClassifier(SEGMENTATION_CLASSIFIER_MODEL_FILE, "");

    if (!HEADLESS) {
        // Setting up console window...
        main.initConsoleWindow();
        main.showConsoleWindow(true);
    }

    // ------------------------------------------------------------------------------------------------------
    // ------------------------------------------------------------------------------------------------------
    final MoMAModel mmm = new MoMAModel(main);
    instance = main;
    try {
        main.processDataFromFolder(path, minTime, maxTime, minChannelIdx, numChannels);
    } catch (final Exception e) {
        e.printStackTrace();
        System.exit(11);
    }
    // ------------------------------------------------------------------------------------------------------
    // ------------------------------------------------------------------------------------------------------

    // show loaded and annotated data
    if (showIJ) {
        new ImageJ();
        ImageJFunctions.show(main.imgRaw, "Rotated & cropped raw data");
        // ImageJFunctions.show( main.imgTemp, "Temporary" );
        // ImageJFunctions.show( main.imgAnnotated, "Annotated ARGB data" );

        // main.getCellSegmentedChannelImgs()
        // ImageJFunctions.show( main.imgClassified, "Classification" );
        // ImageJFunctions.show( main.getCellSegmentedChannelImgs(), "Segmentation" );
    }

    gui = new MoMAGui(mmm);

    if (!HEADLESS) {
        System.out.print("Build GUI...");
        main.showConsoleWindow(false);

        //         final JFrameSnapper snapper = new JFrameSnapper();
        //         snapper.addFrame( main.frameConsoleWindow );
        //         snapper.addFrame( guiFrame );

        gui.setVisible(true);
        guiFrame.add(gui);
        guiFrame.setSize(GUI_WIDTH, GUI_HEIGHT);
        guiFrame.setLocation(GUI_POS_X, GUI_POS_Y);
        guiFrame.setVisible(true);

        //         SwingUtilities.invokeLater( new Runnable() {
        //
        //            @Override
        //            public void run() {
        //               snapper.snapFrames( main.frameConsoleWindow, guiFrame, JFrameSnapper.EAST );
        //            }
        //         } );
        System.out.println(" done!");
    } else {
        //         final String name = inputFolder.getName();

        gui.exportHtmlOverview();
        gui.exportDataFiles();

        instance.saveParams();

        System.exit(0);
    }
}

From source file:Main.java

private static boolean loadLibrary(String Name) {
    boolean result = true;

    Log.d(TAG, "Trying to load library " + Name);
    try {/*from   w w w .ja v a  2 s.  c om*/
        System.loadLibrary(Name);
        Log.d(TAG, "Library " + Name + " loaded");
    } catch (UnsatisfiedLinkError e) {
        Log.d(TAG, "Cannot load library \"" + Name + "\"");
        e.printStackTrace();
        result &= false;
    }

    return result;
}

From source file:Main.java

private static boolean loadLibrary(String Name) {
    boolean result = true;

    Log.d(TAG, "Trying to load library " + Name);
    try {//from   w w  w  . j a  v a  2 s .  c  o m
        System.loadLibrary(Name);
        Log.d(TAG, "OpenCV libs init was ok!");
    } catch (UnsatisfiedLinkError e) {
        Log.d(TAG, "Cannot load library \"" + Name + "\"");
        e.printStackTrace();
        result &= false;
    }

    return result;
}

From source file:Main.java

static void loadLibrary() {
    if (loaded)//from w ww .j  ava 2  s.co m
        return;

    try {
        System.loadLibrary("openal");
        loaded = true;
    } catch (UnsatisfiedLinkError e) {
        System.err.println("Native code library failed to load.");
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:fuse4j.hadoopfs.FuseHdfsClient.java

public static void doMount(String hdfsurl, String username, String[] remainingArgs) {
    try {/*from www . j  a  v  a 2 s.  com*/
        FuseMount.mount(remainingArgs, new FuseHdfsClient(hdfsurl, username), log);
    } catch (UnsatisfiedLinkError e) {
        log.warn("java.library.path is [" + System.getProperty("java.library.path") + "]");
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        log.info("exiting");
    }
}

From source file:edu.cornell.med.icb.goby.modes.MethylationRateVCFOutputFormat.java

public void defineColumns(final OutputInfo outputInfo, final DiscoverSequenceVariantsMode mode) {
    deAnalyzer = mode.getDiffExpAnalyzer();
    deCalculator = mode.getDiffExpCalculator();
    groups = mode.getGroups();/*from  w ww .  j  a  v a 2  s .  c  o  m*/
    samples = mode.getSamples();

    this.outputInfo = outputInfo;
    estimateIntraGroupDifferences = doc.getBoolean("estimate-intra-group-differences");
    estimateEmpiricalP = doc.getBoolean("estimate-empirical-P");
    fixedWindowEmpiricalPSignificanceThreshold = doc.getDouble("significance-threshold");
    final int windowLength = doc.getInteger("window-length");

    readerIndexToGroupIndex = mode.getReaderIndexToGroupIndex();
    final ObjectArrayList<ReadIndexStats> readIndexStats = mode.getReadIndexStats();
    final VCFWriter vcfWriter = new VCFWriter(
            estimateIntraGroupDifferences ? new NullWriter() : outputInfo.getPrintWriter());
    this.statWriter = vcfWriter;
    groupComparisons = mode.getGroupComparisons();
    int maxComparisonIndex = -1;
    for (final GroupComparison comparison : groupComparisons) {
        maxComparisonIndex = Math.max(comparison.index, maxComparisonIndex);
    }
    fixedWindow = new SitesInFixedWindow[maxComparisonIndex + 1];
    for (final GroupComparison comparison : groupComparisons) {
        fixedWindow[comparison.index] = new SitesInFixedWindow(windowLength);
    }

    try {
        //activate R only if we need it:
        final Rengine rEngine = GobyRengine.getInstance().getRengine();
        fisherRInstalled = rEngine != null && rEngine.isAlive();
    } catch (java.lang.UnsatisfiedLinkError e) {
        System.out.println("Cannot initialize R");
        e.printStackTrace();
        throw e;
    }
    if (groups.length < 1) {
        System.err.println("Methylation format requires at least one group.");
        System.exit(1);
    }

    this.readIndexStats = readIndexStats;

    log2OddsRatioColumnIndex = new int[groupComparisons.size()];
    log2OddsRatioStandardErrorColumnIndex = new int[groupComparisons.size()];
    log2OddsRatioZColumnIndex = new int[groupComparisons.size()];
    fisherExactPValueColumnIndex = new int[groupComparisons.size()];
    empiricalPValueColumnIndex = new int[groupComparisons.size()];
    deltaMRColumnIndex = new int[groupComparisons.size()];
    lastOfDMRIndex = new int[groupComparisons.size()];

    numberOfGroups = groups.length;
    statWriter.setWriteFieldGroupAssociations(writeFieldGroupAssociations);
    biomartFieldIndex = statWriter.defineField("INFO", "BIOMART_COORDS", 1, ColumnType.String,
            "Coordinates for use with Biomart.", "biomart");
    strandFieldIndex = statWriter.defineField("INFO", "Strand", 1, ColumnType.String,
            "Strand of the cytosine site on the reference sequence.", "genomic-coordinate");

    genomicContextIndex = statWriter.defineField("INFO", "Context", 1, ColumnType.String,
            "Site genomic context", /*  mark CpG context for indexing: */ "indexed");

    for (GroupComparison comparison : groupComparisons) {
        log2OddsRatioColumnIndex[comparison.index] = statWriter.defineField("INFO",
                String.format("LOD[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1, ColumnType.Float,
                String.format("Log2 of the odds-ratio of observing methylation in  group %s versus group %s",
                        comparison.nameGroup1, comparison.nameGroup2),
                "statistic");

        log2OddsRatioStandardErrorColumnIndex[comparison.index] = statWriter.defineField("INFO",
                String.format("LOD_SE[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                ColumnType.Float,
                String.format("Standard Error of the log2 of the odds-ratio between group %s and group %s",
                        comparison.nameGroup1, comparison.nameGroup2),
                "LOD", "statistic");

        log2OddsRatioZColumnIndex[comparison.index] = statWriter.defineField("INFO",
                String.format("LOD_Z[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                ColumnType.Float, String.format("Z value of the odds-ratio between group %s and group %s",
                        comparison.nameGroup1, comparison.nameGroup2),
                "LOD", "statistic");

        fisherExactPValueColumnIndex[comparison.index] = statWriter.defineField("INFO",
                String.format("FisherP[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                ColumnType.Float,
                String.format(
                        "Fisher exact P-value of observing as large a difference by chance between group %s and group %s.",
                        comparison.nameGroup1, comparison.nameGroup2),
                "p-value");

        deltaMRColumnIndex[comparison.index] = statWriter.defineField("INFO",
                String.format("Delta_MR[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                ColumnType.Integer,
                String.format("Absolute Difference in methylation between group %s and group %s",
                        comparison.nameGroup1, comparison.nameGroup2),
                "statistic");
        if (estimateEmpiricalP) {
            empiricalPValueColumnIndex[comparison.index] = statWriter.defineField("INFO",
                    String.format("empiricalP[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                    ColumnType.Float,
                    String.format(
                            "Empirical P-value of observing as large a difference by chance between group %s and group %s.",
                            comparison.nameGroup1, comparison.nameGroup2),
                    "p-value", "statistic", "indexed");

            lastOfDMRIndex[comparison.index] = statWriter.defineField("INFO",
                    String.format("DMR[%s/%s]", comparison.nameGroup1, comparison.nameGroup2), 1,
                    ColumnType.Integer,
                    String.format(
                            "Number of significant sites observed in a fixed window of length %d before this significant site (inclusive). Comparing group %s and group %s.",
                            windowLength, comparison.nameGroup1, comparison.nameGroup2),
                    "DMR", "indexed");
        }

    }
    methylationRatePerGroupIndex = new int[groups.length];
    for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
        methylationRatePerGroupIndex[groupIndex] = statWriter.defineField("INFO",
                String.format("MR[%s]", groups[groupIndex]), 1, ColumnType.Float,
                String.format("Methylation rate in group %s.", groups[groupIndex]), "MethylationRate");

    }
    methylatedCCountsIndex = new int[groups.length];
    notMethylatedCCountsIndex = new int[groups.length];

    for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
        notMethylatedCCountsIndex[groupIndex] = statWriter.defineField("INFO",
                String.format("#C_Group[%s]", groups[groupIndex]), 1, ColumnType.Integer,
                String.format("Number of unmethylated Cytosines at site in group %s.", groups[groupIndex]),
                "#C");
        methylatedCCountsIndex[groupIndex] = statWriter.defineField("INFO",
                String.format("#Cm_Group[%s]", groups[groupIndex]), 1, ColumnType.Integer,
                String.format("Number of methylated Cytosines at site in group %s.", groups[groupIndex]),
                "#Cm");
    }
    depthFieldIndex = statWriter.defineField("INFO", "DP", 1, ColumnType.Integer,
            "Total depth of sequencing across groups at this site", "Depth");
    {
        // define one VCF 'sample' for each strand of each input sample:
        String[] sampleTwice = new String[samples.length * 2];
        int sampleIndex = 0;
        for (String sample : samples) {
            sampleTwice[sampleIndex++] = "+|" + sample;
        }
        for (String sample : samples) {
            sampleTwice[sampleIndex++] = "-|" + sample;
        }

        statWriter.defineSamples(sampleTwice);
    }
    // define Genotype as first field (required by VCF specification):
    genotypeFormatter.defineGenotypeField(statWriter);
    methylationRateFieldIndex = statWriter.defineField("FORMAT", "MR", 1, ColumnType.Integer,
            "Methylation rate. 0-100%, 100% indicate fully methylated.", "MethylationRate");
    convertedCytosineFieldIndex = statWriter.defineField("FORMAT", "C", 1, ColumnType.Integer,
            "Number of converted cytosines at site.", "#C");
    unconvertedCytosineFieldIndex = statWriter.defineField("FORMAT", "Cm", 1, ColumnType.Integer,
            "Number of unconverted cytosines at site", "#Cm");

    // setup empirical p-value estimator:
    String statName = doc.getString("statistic");
    if (!statName.endsWith("_mci")) {

        // do not append several times
        statName = statName + "_mci";
    }
    // override the stat name with the mci provider variant:
    doc.setValue("statistic", statName);
    empiricalPValueEstimator = new EmpiricalPValueEstimator();
    empiricalPValueEstimator.configure(1, doc);
    empiricalPValueEstimator.setGroupEnumerator(new SamplePairEnumerator(readerIndexToGroupIndex,
            samples.length, groups.length, groupComparisons.size()));

    if (estimateIntraGroupDifferences || estimateEmpiricalP) {
        empiricalPValueEstimator.recordWithinGroupSamplePairs(groups);
        for (final GroupComparison comparison : groupComparisons) {

            empiricalPValueEstimator.recordBetweenGroupsSamplePairs(comparison);
        }
    }
    statWriter.writeHeader();
}

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

@Provides
@Singleton// w w  w  . java 2 s .  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();
}