List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace(PrintWriter s)
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); t.printStackTrace(System.out); }
From source file:Main.java
public static void main(String[] argv) throws FileNotFoundException { Throwable t = new Exception("from java2s.com"); t.printStackTrace(new PrintWriter("file.name")); }
From source file:com.nokia.dempsy.spring.RunAppInVm.java
public static void main(String[] args) { try {//from w ww.j a v a2 s . co m run(args); } catch (Throwable e) { e.printStackTrace(System.err); System.err.flush(); System.exit(1); } System.exit(0); }
From source file:net.erdfelt.android.sdkfido.Main.java
public static void main(String[] args) { Logging.config();/* w w w. j a v a2s. co m*/ Main main = new Main(); try { main.execute(args); } catch (Throwable t) { t.printStackTrace(System.err); } }
From source file:com.marklogic.tableauextract.ExtractFromJSON.java
public static void main(String[] args) { try {// ww w .j ava2s . c o m // Initialize Tableau Extract API ExtractAPI.initialize(); try (Extract extract = new Extract("claim-java.tde")) { Table table; if (!extract.hasTable("Extract")) { // Table does not exist; create it TableDefinition tableDef = makeTableDefinition(); table = extract.addTable("Extract", tableDef); } else { // Open an existing table to add more rows table = extract.openTable("Extract"); } TableDefinition tableDef = table.getTableDefinition(); printTableDefinition(tableDef); insertData(table); } // Clean up Tableau Extract API ExtractAPI.cleanup(); } catch (Throwable t) { t.printStackTrace(System.err); } }
From source file:eu.interedition.collatex.tools.CollateX.java
public static void main(String... args) { try {/*from www . j a v a 2 s . co m*/ final CommandLine commandLine = new GnuParser().parse(OPTIONS, args); if (commandLine.hasOption("h")) { help(); } else if (commandLine.hasOption("S")) { CollationServer.start(commandLine); } else { CollationPipe.start(commandLine); } } catch (ParseException e) { error("Error while parsing command line arguments (-h for usage instructions)", e); } catch (IllegalArgumentException e) { error("Illegal argument", e); } catch (IOException e) { error("I/O error", e); } catch (SAXException e) { error("XML error", e); } catch (XPathExpressionException e) { error("XPath error", e); } catch (ScriptException | PluginScript.PluginScriptExecutionException e) { error("Script error", e); } catch (Throwable t) { error("Unexpected error", t); t.printStackTrace(ERROR_LOG); } finally { ERROR_LOG.flush(); } }
From source file:io.mindmaps.migration.csv.Main.java
public static void main(String[] args) { String csvFileName = null;//from ww w .j a va 2s .c o m String csvEntityType = null; String engineURL = null; String graphName = null; for (int i = 0; i < args.length; i++) { if ("-file".equals(args[i])) csvFileName = args[++i]; else if ("-graph".equals(args[i])) graphName = args[++i]; else if ("-engine".equals(args[i])) engineURL = args[++i]; else if ("-as".equals(args[i])) { csvEntityType = args[++i]; } else if ("csv".equals(args[0])) { continue; } else die("Unknown option " + args[i]); } if (csvFileName == null) { die("Please specify CSV file using the -csv option"); } File csvFile = new File(csvFileName); if (!csvFile.exists()) { die("Cannot find file: " + csvFileName); } if (graphName == null) { die("Please provide the name of the graph using -graph"); } if (csvEntityType == null) { csvEntityType = csvFile.getName().replaceAll("[^A-Za-z0-9]", "_"); } System.out.println("Migrating " + csvFileName + " using MM Engine " + (engineURL == null ? "local" : engineURL) + " into graph " + graphName); // perform migration CSVSchemaMigrator schemaMigrator = new CSVSchemaMigrator(); CSVDataMigrator dataMigrator = new CSVDataMigrator(); // try { MindmapsGraph graph = engineURL == null ? MindmapsClient.getGraph(graphName) : MindmapsClient.getGraph(graphName, engineURL); Loader loader = engineURL == null ? new BlockingLoader(graphName) : new DistributedLoader(graphName, Lists.newArrayList(engineURL)); CSVParser csvParser = CSVParser.parse(csvFile.toURI().toURL(), StandardCharsets.UTF_8, CSVFormat.DEFAULT.withHeader()); schemaMigrator.graph(graph).configure(csvEntityType, csvParser).migrate(loader); System.out.println("Schema migration successful"); dataMigrator.graph(graph).configure(csvEntityType, csvParser).migrate(loader); System.out.println("DataType migration successful"); } catch (Throwable throwable) { throwable.printStackTrace(System.err); } System.exit(0); }
From source file:com.twitter.distributedlog.messaging.ConsoleProxyRRMultiWriter.java
public static void main(String[] args) throws Exception { if (2 != args.length) { System.out.println(HELP); return;// w w w .ja v a2 s . c o m } String finagleNameStr = args[0]; final String streamList = args[1]; DistributedLogClient client = DistributedLogClientBuilder.newBuilder() .clientId(ClientId.apply("console-proxy-writer")).name("console-proxy-writer").thriftmux(true) .finagleNameStr(finagleNameStr).build(); String[] streamNameList = StringUtils.split(streamList, ','); RRMultiWriter<Integer, String> writer = new RRMultiWriter(streamNameList, client); // Setup Terminal Terminal terminal = Terminal.setupTerminal(); ConsoleReader reader = new ConsoleReader(); String line; while ((line = reader.readLine(PROMPT_MESSAGE)) != null) { writer.write(line).addEventListener(new FutureEventListener<DLSN>() { @Override public void onFailure(Throwable cause) { System.out.println("Encountered error on writing data"); cause.printStackTrace(System.err); Runtime.getRuntime().exit(0); } @Override public void onSuccess(DLSN value) { // done } }); } client.close(); }
From source file:embedding.ExampleJava2D2PDF.java
/** * Main method./*w w w .ja va 2 s. co m*/ * @param args command-line arguments */ public static void main(String[] args) { try { System.out.println("FOP " + ExampleJava2D2PDF.class.getSimpleName() + "\n"); System.out.println("Preparing..."); //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); if (!outDir.isDirectory()) { if (!outDir.mkdirs()) { throw new IOException("Could not create output directory: " + outDir); } } //Setup output file File pdffile = new File(outDir, "ResultJava2D2PDF.pdf"); System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Generating..."); ExampleJava2D2PDF app = new ExampleJava2D2PDF(); app.generatePDF(pdffile); System.out.println("Success!"); } catch (Throwable t) { t.printStackTrace(System.err); System.exit(-1); } }
From source file:utilities.MinPopulateDatabase.java
public static void main(String[] args) { ApplicationContext populationContext; DatabaseUtil databaseUtil;/*from w w w. java 2 s . co m*/ databaseUtil = null; try { System.out.printf("MinPopulateDatabase 1.3%n"); System.out.printf("--------------------%n%n"); System.out.printf("Initialising persistence context `%s'...%n", DatabaseConfig.PersistenceUnit); databaseUtil = new DatabaseUtil(); System.out.printf("Creating database `%s' (%s)...%n", databaseUtil.getDatabaseName(), databaseUtil.getDatabaseDialectName()); databaseUtil.recreateDatabase(); System.out.printf("Reading configuration file `%s'...%n", "MinPopulateDatabase.xml"); populationContext = new ClassPathXmlApplicationContext("classpath:minPopulateDatabase.xml"); System.out.printf("Persisting %d entities...%n%n", populationContext.getBeanDefinitionCount()); databaseUtil.openTransaction(); for (Entry<String, Object> entry : populationContext.getBeansWithAnnotation(Entity.class).entrySet()) { String beanName; DomainEntity entity; beanName = entry.getKey(); entity = (DomainEntity) entry.getValue(); System.out.printf("> %s: %s", beanName, entity.getClass().getName()); databaseUtil.persist(entity); System.out.printf(" -> id = %d, version = %d%n", entity.getId(), entity.getVersion()); } databaseUtil.commitTransaction(); } catch (Throwable oops) { System.out.flush(); System.err.printf("%n%s%n", oops.getLocalizedMessage()); oops.printStackTrace(System.err); } finally { if (databaseUtil != null) databaseUtil.close(); } }