Example usage for java.lang Throwable printStackTrace

List of usage examples for java.lang Throwable printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:LegacyTest.java

public static void main(String[] args) {
    try {/*from   w  w  w.  j a  v a2s .c  om*/
        PdfAs pdfAS = PdfAsFactory.createPdfAs();

        SignParameters signParameters = new SignParameters();
        signParameters.setSignatureDevice("bku");
        signParameters.setSignatureProfileId("SIGNATURBLOCK_DE");

        InputStream is = LegacyTest.class.getResourceAsStream("simple.pdf");

        byte[] inputData = IOUtils.toByteArray(is);
        ByteArrayDataSink bads = new ByteArrayDataSink();
        signParameters.setDocument(new ByteArrayDataSource(inputData));
        signParameters.setOutput(bads);
        SignResult result = pdfAS.sign(signParameters);
        IOUtils.write(bads.getBytes(), new FileOutputStream("/tmp/test.pdf"));

        System.out.println("Signed @ " + result.getSignaturePosition().toString());
        System.out.println("Signed by " + result.getSignerCertificate().getSubjectDN().getName());

        VerifyParameters verifyParameters = new VerifyParameters();
        verifyParameters.setDocument(new ByteArrayDataSource(bads.getBytes()));
        verifyParameters.setSignatureToVerify(0);

        VerifyResults results = pdfAS.verify(verifyParameters);

        Iterator iter = results.getResults().iterator();

        while (iter.hasNext()) {
            Object obj = iter.next();
            if (obj instanceof VerifyResult) {
                VerifyResult vresult = (VerifyResult) obj;
                System.out.println("Verified: " + vresult.getValueCheckCode().getCode() + " "
                        + vresult.getValueCheckCode().getMessage());
            }
        }

    } catch (Throwable e) {
        System.out.println("ERROR");
        e.printStackTrace();
    }
}

From source file:licenceexecuter.LicenceExecuter.java

/**
 * @param args the command line arguments
 * @throws java.text.ParseException// w  w w  .  ja  v a2 s. c o m
 */
public static void main(String[] args) throws Throwable {
    LicenceExecuter licenceExecuter = new LicenceExecuter();
    licenceExecuter.initProperties();

    if (args != null && args.length >= 5) {
        System.out.println(Base64.encodeBase64String(args[4].getBytes()));
        System.out.println(licenceExecuter.properties.getProperty("generateKey"));
        if (Base64.encodeBase64String(args[4].getBytes())
                .equals(licenceExecuter.properties.getProperty("generateKey"))) {
            System.out.println(ControllerKey.encrypt(
                    new ObKeyExecuter().toObject(args[0] + "|" + args[1] + "|" + args[2] + "|" + args[3])));
        } else {
            throw new IllegalArgumentException("InvalidPassword");
        }
        return;
    }
    try {
        licenceExecuter.run();
    } catch (Throwable ex) {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, "PROBLEMAS NA EXECUO", "ATENO", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:edu.pitt.csb.mgm.ExploreIndepTests.java

public static void main(String[] args) {
    //        Graph g = new EdgeListGraph();
    //        g.addNode(new ContinuousVariable("X1"));
    //        g.addNode(new ContinuousVariable("X2"));
    //        g.addNode(new DiscreteVariable("X3", 4));
    //        g.addNode(new DiscreteVariable("X4", 4));
    //        g.addNode(new ContinuousVariable("X5"));
    ////from  w  w w .  j a v  a 2 s .c  om
    //        g.addDirectedEdge(g.getNode("X1"), g.getNode("X2"));
    //        g.addDirectedEdge(g.getNode("X2"), g.getNode("X3"));
    //        g.addDirectedEdge(g.getNode("X3"), g.getNode("X4"));
    //        g.addDirectedEdge(g.getNode("X4"), g.getNode("X5"));
    //
    //        GeneralizedSemPm pm = MixedUtils.GaussianCategoricalPm(g, "Split(-1.5,-.5,.5,1.5)");
    ////        System.out.println(pm);
    //
    //        GeneralizedSemIm im = MixedUtils.GaussianCategoricalIm(pm);
    ////        System.out.println(im);
    //
    //        int samps = 200;
    //        DataSet ds = im.simulateDataAvoidInfinity(samps, false);
    //        ds = MixedUtils.makeMixedData(ds, MixedUtils.getNodeDists(g));
    //        //System.out.println(ds);
    //        System.out.println(ds.isMixed());
    try {
        String path = ExampleMixedSearch.class.getResource("test_data").getPath();
        Graph trueGraph = SearchGraphUtils
                .patternFromDag(GraphUtils.loadGraphTxt(new File(path, "DAG_0_graph.txt")));
        DataSet ds = MixedUtils.loadDataSet(path, "DAG_0_data.txt");

        IndTestMultinomialLogisticRegression indMix = new IndTestMultinomialLogisticRegression(ds, .05);
        IndTestMultinomialLogisticRegressionWald indWalLin = new IndTestMultinomialLogisticRegressionWald(ds,
                .05, true);
        IndTestMultinomialLogisticRegressionWald indWalLog = new IndTestMultinomialLogisticRegressionWald(ds,
                .05, false);

        PcStable s1 = new PcStable(indMix);
        PcStable s2 = new PcStable(indWalLin);
        PcStable s3 = new PcStable(indWalLog);

        long time = System.currentTimeMillis();
        Graph g1 = SearchGraphUtils.patternFromDag(s1.search());
        System.out.println("Mix Time " + ((System.currentTimeMillis() - time) / 1000.0));

        time = System.currentTimeMillis();
        Graph g2 = SearchGraphUtils.patternFromDag(s2.search());
        System.out.println("Wald lin Time " + ((System.currentTimeMillis() - time) / 1000.0));

        time = System.currentTimeMillis();
        Graph g3 = SearchGraphUtils.patternFromDag(s3.search());
        System.out.println("Wald log Time " + ((System.currentTimeMillis() - time) / 1000.0));

        //            System.out.println(g);
        //            System.out.println("IndMix: " + s1.search());
        //            System.out.println("IndWalLin: " + s2.search());
        //            System.out.println("IndWalLog: " + s3.search());

        System.out.println(MixedUtils.EdgeStatHeader);
        System.out.println(MixedUtils.stringFrom2dArray(MixedUtils.allEdgeStats(trueGraph, g1)));
        System.out.println(MixedUtils.stringFrom2dArray(MixedUtils.allEdgeStats(trueGraph, g2)));
        System.out.println(MixedUtils.stringFrom2dArray(MixedUtils.allEdgeStats(trueGraph, g3)));
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:eu.leads.crawler.c4j.LeadsWP5DemoCrawlController.java

public static void main(String[] args) {
    LeadsWP5DemoCrawlController controller = new LeadsWP5DemoCrawlController();
    String site = args[0];//from  w ww .j a v  a 2s .  c o  m
    try {
        controller.crawlDomain(site);
    } catch (Throwable e) {
        e.printStackTrace();
        System.exit(-1);
    }
    System.exit(0);
}

From source file:com.tesora.dve.common.PECryptoUtils.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("Usage: " + PECryptoUtils.class.getName() + " <password>");
        return;/*from w  w  w.ja va2  s. c  o m*/
    }

    try {
        System.out.println();
        System.out.println("  " + args[0] + " ==> " + encrypt(args[0]));
        System.out.println();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:com.mobius.software.mqtt.performance.controller.ControllerRunner.java

public static void main(String[] args) {
    try {/*from w w  w. j av a  2s.  c  o m*/
        /*URI baseURI = URI.create(args[0].replace("-baseURI=", ""));
        configFile = args[1].replace("-configFile=", "");*/
        String userDir = System.getProperty("user.dir");
        System.out.println("user.dir: " + userDir);
        setConfigFilePath(userDir + "/config.properties");
        Properties prop = new Properties();
        prop.load(new FileInputStream(configFile));
        System.out.println("properties loaded...");

        String hostname = prop.getProperty("hostname");
        Integer port = Integer.parseInt(prop.getProperty("port"));
        URI baseURI = new URI(null, null, hostname, port, null, null, null);

        configureConsoleLogger();
        System.out.println("starting http server...");
        JerseyServer server = new JerseyServer(baseURI);
        System.out.println("http server started");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("press any key to stop: ");
        br.readLine();
        server.terminate();
    } catch (Throwable e) {
        logger.error("AN ERROR OCCURED: " + e.getMessage());
        e.printStackTrace();
    } finally {
        System.exit(0);
    }
}

From source file:caarray.client.examples.java.DownloadMageTabExport.java

public static void main(String[] args) {
    DownloadMageTabExport downloader = new DownloadMageTabExport();
    try {/*www. j a v  a  2  s.  c  om*/
        CaArrayServer server = new CaArrayServer(BaseProperties.getServerHostname(),
                BaseProperties.getServerJndiPort());
        server.connect();
        searchService = server.getSearchService();
        dataService = server.getDataService();
        System.out.println("Exporting MAGE-TAB of experiment: " + EXPERIMENT_TITLE + "...");
        downloader.download();
    } catch (Throwable t) {
        System.out.println("Error while downloading MAGE-TAB export.");
        t.printStackTrace();
    }
}

From source file:at.gv.egiz.pdfas.cli.test.SignaturProfileTest.java

public static void main(String[] args) {
    String user_home = System.getProperty("user.home");
    String pdfas_dir = user_home + File.separator + ".pdfas";
    PdfAs pdfas = PdfAsFactory.createPdfAs(new File(pdfas_dir));
    try {/*w ww .j a  v a 2 s. co  m*/
        Configuration config = pdfas.getConfiguration();
        ISettings settings = (ISettings) config;
        List<String> signatureProfiles = new ArrayList<String>();

        List<String> signaturePDFAProfiles = new ArrayList<String>();

        Iterator<String> itKeys = settings.getFirstLevelKeys("sig_obj.types.").iterator();
        while (itKeys.hasNext()) {
            String key = itKeys.next();
            String profile = key.substring("sig_obj.types.".length());
            System.out.println("[" + profile + "]: " + settings.getValue(key));
            if (settings.getValue(key).equals("on")) {
                signatureProfiles.add(profile);
                if (profile.contains("PDFA")) {
                    signaturePDFAProfiles.add(profile);
                }
            }
        }

        byte[] input = IOUtils.toByteArray(new FileInputStream(sourcePDF));

        IPlainSigner signer = new PAdESSignerKeystore(KS_FILE, KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE);

        Iterator<String> itProfiles = signatureProfiles.iterator();
        while (itProfiles.hasNext()) {
            String profile = itProfiles.next();
            System.out.println("Testing " + profile);

            DataSource source = new ByteArrayDataSource(input);

            FileOutputStream fos = new FileOutputStream(targetFolder + profile + ".pdf");
            SignParameter signParameter = PdfAsFactory.createSignParameter(config, source, fos);

            signParameter.setPlainSigner(signer);
            signParameter.setSignatureProfileId(profile);

            SignResult result = pdfas.sign(signParameter);

            fos.close();
        }

        byte[] inputPDFA = IOUtils.toByteArray(new FileInputStream(sourcePDFA));

        Iterator<String> itPDFAProfiles = signaturePDFAProfiles.iterator();
        while (itPDFAProfiles.hasNext()) {
            String profile = itPDFAProfiles.next();
            System.out.println("Testing " + profile);

            DataSource source = new ByteArrayDataSource(inputPDFA);
            FileOutputStream fos = new FileOutputStream(targetFolder + "PDFA_" + profile + ".pdf");
            SignParameter signParameter = PdfAsFactory.createSignParameter(config, source, fos);

            signParameter.setPlainSigner(signer);
            signParameter.setSignatureProfileId(profile);

            SignResult result = pdfas.sign(signParameter);

            fos.close();
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

From source file:caarray.client.examples.grid.DownloadFile.java

public static void main(String[] args) {
    DownloadFile fileDownloader = new DownloadFile();
    try {/*from w w w . j  a  v a 2  s.  c  om*/
        client = new CaArraySvc_v1_0Client(BaseProperties.getGridServiceUrl());
        searchServiceHelper = new GridSearchApiUtils(client);
        System.out.println("Downloading file contents from " + DATA_FILE_NAME + " in experiment: "
                + EXPERIMENT_TITLE + "...");
        fileDownloader.download();
    } catch (Throwable t) {
        System.out.println("Error while downloading file.");
        t.printStackTrace();
    }
}

From source file:com.ms.commons.standalone.job.JobRunner.java

public static void main(String[] args) throws JobExecutionException {
    logger.error("__start of job, args is " + StringUtils.join(args, ", "));
    // try and catch everything
    try {/*from   w w  w.  jav  a2 s  . com*/
        checkArgs(args);
        JobAction jobAction = JobAction.valueOf(args[0].trim());
        String fullClassName = args[1].trim();
        String[] NewArgs = getNewArgs(args);

        AbstractJob job = getJobInstanceByClassName(fullClassName);
        job.setArgs(NewArgs);

        clearStandaloneStopFile();

        switch (jobAction) {
        case start:
            job.execute(null);
            break;
        case startNohup:
            job.execute(null);
            break;
        case startWithDebug:
            job.execute(null);
            break;
        case stop:
            stopJob();
            break;
        default:
            throw new RuntimeException("jobAction must be start or stop");
        }
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        t.printStackTrace();
    }
    logger.error("__end of job, args is " + StringUtils.join(args, ", "));
    System.exit(0);
}