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:Uncaught.java

public static void main(String[] args) {
    Thread thread = new Thread(new Uncaught());
    thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
        }//from  www  .  j ava2 s. co m
    });
    thread.start();
}

From source file:Main.java

public static void main(String[] args) {
    Thread thread = new Thread() {
        public void run() {
            throw new NullPointerException();
        }/*from  w  w  w  . j  av a  2s.co  m*/
    };
    thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread arg0, Throwable arg1) {
            arg1.printStackTrace();
        }
    });
    thread.start();
}

From source file:Main.java

public static void main(String str[]) {
    final Object monitor = new Object();
    new Thread() {
        public void run() {
            try {
                synchronized (monitor) {
                    System.out.println("10 seconds ...");
                    monitor.wait(10000);
                    System.out.println("Wait over");
                }/*from   ww w. j a  v  a2 s .  co m*/
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }.start();
}

From source file:Main.java

public static void main(String[] argv) {
    Throwable t = new Exception("from java2s.com");

    t.printStackTrace();

}

From source file:org.btc4j.jms.BtcDaemonListenerMain.java

public static void main(String[] args) {
    try {//from w w  w .  ja v  a2 s .c o m
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("btc4j-jms-test.xml");
        BtcDaemonCaller caller = (BtcDaemonCaller) ctx.getBean("daemonCaller");
        System.out.println(caller.sendReceive("BTCAPI.JSON_RPC.INVOKE",
                "{\"jsonrpc\":\"2.0\",\"method\":\"help\",\"params\":[\"getblock\"],\"id\":\"400ec474-5b67-4f82-bb65-4e10ee807d04\"}"));
        ctx.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:org.btc4j.ws.BtcDaemonServiceMain.java

public static void main(String[] args) {
    try {//from   w  ww.  ja  v  a  2  s  . co m
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("btc4j-ws-test.xml");
        BtcDaemonServicePort daemon = (BtcDaemonServicePort) ctx.getBean("btcDaemonService");
        //System.out.println("help: " + daemon.help("walletlock"));
        System.out.println("getAddressesByAccount: " + daemon.getAddressesByAccount("user"));
        //daemon.stop();
        ctx.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:edu.berkeley.compbio.ncbitaxonomy.Exporter.java

public static void main(String[] argv) {
    try {/*ww  w  . j a  va2  s  .  co  m*/
        ApplicationContext ctx = NcbiTaxonomyDbContextFactory.makeNcbiTaxonomyDbContext();
        NcbiTaxonomyPhylogeny ncbi = (NcbiTaxonomyPhylogeny) ctx.getBean("ncbiTaxonomyPhylogeny");

        FileWriter treeWriter = new FileWriter("tree.newick");
        ncbi.toNewick(treeWriter, "", "", 0, 0);
        treeWriter.close();

        FileWriter synonymWriter = new FileWriter("synonyms");
        ncbi.writeSynonyms(synonymWriter);
        synonymWriter.close();

        for (String rank : ranks) {
            FileWriter rankWriter = new FileWriter(rank);
            Set<Integer> ids = ncbi.getTaxIdsWithRank(rank);
            for (Integer id : ids) {
                rankWriter.append(id.toString()).append("\n");
            }
            rankWriter.close();
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

From source file:com.github.cmis4j.ws.CmisRepositoryMain.java

@SuppressWarnings("unused")
public static void main(String[] args) {
    try {//from  w  w  w .  j  a v a2 s  .  c o m
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("cmis4j-ws-test.xml");
        ACLServicePort aclService = (ACLServicePort) ctx.getBean("aclService");
        DiscoveryServicePort discoveryService = (DiscoveryServicePort) ctx.getBean("discoveryService");
        MultiFilingServicePort multiFilingService = (MultiFilingServicePort) ctx.getBean("multiFilingService");
        NavigationServicePort navigationService = (NavigationServicePort) ctx.getBean("navigationService");
        ObjectServicePort objectService = (ObjectServicePort) ctx.getBean("objectService");
        PolicyServicePort policyService = (PolicyServicePort) ctx.getBean("policyService");
        RelationshipServicePort relationshipService = (RelationshipServicePort) ctx
                .getBean("relationshipService");
        RepositoryServicePort repositoryService = (RepositoryServicePort) ctx.getBean("repositoryService");
        VersioningServicePort versioningService = (VersioningServicePort) ctx.getBean("versioningService");
        ctx.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:testReflection.java

public static void main(String[] args) {
    try {// w w  w .ja va2  s. c  o m
        C c = new C();
        Class klass = c.getClass();
        Field[] fields = getAllFields(klass);
        for (Field field : fields) {
            System.out.println(field.getName());
        }
    } catch (Throwable a_th) {
        a_th.printStackTrace();
    }
}

From source file:fr.jamgotchian.tuplegen.core.Main.java

public static void main(String[] args) {
    CommandLineParser parser = new PosixParser();

    try {//  w  ww  . j av  a2 s  .co  m
        CommandLine line = parser.parse(OPTIONS, args);
        if (line.hasOption("h") || !line.hasOption("c") || !line.hasOption("d")) {
            usage();
        }
        File genSrcDir = new File(line.getOptionValue("d"));
        if (!genSrcDir.exists()) {
            throw new IllegalArgumentException(genSrcDir + " does not exit");
        }
        if (!genSrcDir.isDirectory()) {
            throw new IllegalArgumentException(genSrcDir + " should be a directory");
        }
        File cfgFile = new File(line.getOptionValue("c"));
        if (!cfgFile.exists()) {
            throw new IllegalArgumentException(cfgFile + " does not exist");
        }
        TupleGen generator = new TupleGen();
        generator.generate(cfgFile, genSrcDir, false, LOGGER);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}