List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:mitm.application.djigzo.tools.CLITool.java
public static void main(String[] args) throws Exception { CLITool tool = new CLITool(); try {/*from ww w . j av a2 s . com*/ tool.handleCommandline(args); } catch (CLIRuntimeException e) { System.err.println(e.getMessage()); System.exit(2); } catch (MissingArgumentException e) { System.err.println("Not all required parameters are specified. " + e.getMessage()); System.exit(3); } catch (ParseException e) { System.err.println("Command line parsing error. " + e); System.exit(4); } catch (WebServiceException e) { Throwable cause = ExceptionUtils.getRootCause(e); if (cause instanceof ConnectException) { System.err.println("Unable to connect to backend. Cause: " + cause.getMessage()); } else { e.printStackTrace(); } System.exit(5); } catch (WSProxyFactoryException e) { e.printStackTrace(); System.exit(6); } catch (WebServiceCheckedException e) { e.printStackTrace(); System.exit(7); } catch (Exception e) { e.printStackTrace(); System.exit(8); } }
From source file:fr.ens.biologie.genomique.eoulsan.Main.java
/** * Main method of the program./*from w w w. j a v a2 s .com*/ * @param args command line arguments */ public static void main(final String[] args) { if (main != null) { throw new IllegalAccessError("Main method cannot be run twice."); } // Set the default local for all the application Globals.setDefaultLocale(); // Check Java version if (getJavaVersion() < MINIMAL_JAVA_VERSION_REQUIRED) { Common.showErrorMessageAndExit(Globals.WELCOME_MSG + "\nError: " + Globals.APP_NAME + " requires Java " + MINIMAL_JAVA_VERSION_REQUIRED + "."); } // Select the application execution mode final String eoulsanMode = System.getProperty(Globals.LAUNCH_MODE_PROPERTY); if (eoulsanMode != null && eoulsanMode.equals("local")) { main = new MainCLI(args); } else { main = new MainHadoop(args); } // Get the action to execute final Action action = main.getAction(); // Get the Eoulsan settings final Settings settings = EoulsanRuntime.getSettings(); // Test if action can be executed with current platform if (!settings.isBypassPlatformChecking() && !action.isCurrentArchCompatible()) { Common.showErrorMessageAndExit(Globals.WELCOME_MSG + "\nError: The " + action.getName() + " of " + Globals.APP_NAME + " is not available for your platform. Required platforms: " + availableArchsToString() + "."); } try { getLogger().info("Start " + action.getName() + " action"); // Run action action.action(main.getActionArgs()); getLogger().info("End of " + action.getName() + " action"); } catch (Throwable e) { Common.errorExit(e, e.getMessage()); } // Flush logs main.flushLog(); }
From source file:net.sf.firemox.Magic.java
/** * @param args// w w w.ja va 2 s. c om * the command line arguments * @throws Exception */ public static void main(String[] args) throws Exception { Log.init(); Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:" + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:" + Toolkit.getDefaultToolkit().getScreenSize().width + "x" + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir()); System.setProperty("swing.aatext", "true"); System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY, MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png")); final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES); if (substancelafFile == null) { Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation"); } else { System.getProperties().load(new FileInputStream(substancelafFile)); } MToolKit.defaultFont = new Font("Arial", 0, 11); try { if (args.length > 0) { final String[] args2 = new String[args.length - 1]; System.arraycopy(args, 1, args2, 0, args.length - 1); if ("-rebuild".equals(args[0])) { XmlConfiguration.main(args2); } else if ("-oracle2xml".equals(args[0])) { Oracle2Xml.main(args2); } else if ("-batch".equals(args[0])) { if ("-server".equals(args[1])) { batchMode = BATCH_SERVER; } else if ("-client".equals(args[1])) { batchMode = BATCH_CLIENT; } } else { Log.error("Unknown options '" + Arrays.toString(args) + "'\nUsage : java -jar starter.jar <options>, where options are :\n" + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n" + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]"); } System.exit(0); return; } if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) { splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000); } // language settings LanguageManager.initLanguageManager(Configuration.getString("language", "auto")); } catch (Throwable t) { Log.error("START-ERROR : \n\t" + t.getMessage()); System.exit(1); return; } Log.debug("MP Language : " + LanguageManager.getLanguage().getName()); speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768; // verify the java version, minimal is 1.5 if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) { Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE); } // load look and feel settings lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME); // try { // FileInputStream in= new FileInputStream("MAGIC.TTF"); // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in); // in.close(); // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11); // } // catch (FileNotFoundException e) { // System.out.println("editorfont.ttf not found, using default."); // } // catch (Exception ex) { // ex.printStackTrace(); // } // Read available L&F final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>(); try { BufferedReader buffReader = new BufferedReader( new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS))); String line; while ((line = buffReader.readLine()) != null) { line = line.trim(); if (!line.startsWith("#")) { final int index = line.indexOf(';'); if (index != -1) { lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1))); } } } IOUtils.closeQuietly(buffReader); } catch (Throwable e) { // no place for resolve this problem Log.debug("Error reading L&F properties : " + e.getMessage()); } for (Pair<String, String> pair : lfList) { UIManager.installLookAndFeel(pair.key, pair.value); } // install L&F if (SkinLF.isSkinLF(lookAndFeelName)) { // is a SkinLF Look & Feel /* * Make sure we have a nice window decoration. */ SkinLF.installSkinLF(lookAndFeelName); } else { // is Metal Look & Feel if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) { // preferred look&feel is not available JOptionPane.showMessageDialog(magicForm, LanguageManager.getString("preferredlfpb", lookAndFeelName), LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE); setDefaultUI(); } // Install the preferred LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName); frameDecorated = newLAF.getSupportsWindowDecorations(); /* * Make sure we have a nice window decoration. */ JFrame.setDefaultLookAndFeelDecorated(frameDecorated); JDialog.setDefaultLookAndFeelDecorated(frameDecorated); UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName)); } // Start main thread try { new Magic(); SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER); } catch (Throwable e) { Log.fatal("In main thread, occurred exception : ", e); ConnectionManager.closeConnexions(); return; } }
From source file:io.cloudslang.lang.tools.build.SlangBuildMain.java
public static void main(String[] args) { loadUserProperties();//w w w.j a va 2 s . com configureLog4j(); ApplicationArgs appArgs = new ApplicationArgs(); parseArgs(args, appArgs); String projectPath = parseProjectPathArg(appArgs); final String contentPath = defaultIfEmpty(appArgs.getContentRoot(), projectPath + CONTENT_DIR); final String testsPath = defaultIfEmpty(appArgs.getTestRoot(), projectPath + TEST_DIR); List<String> testSuites = parseTestSuites(appArgs); boolean shouldPrintCoverageData = appArgs.shouldOutputCoverage(); boolean runTestsInParallel = appArgs.isParallel(); int threadCount = parseThreadCountArg(appArgs, runTestsInParallel); String testCaseTimeout = parseTestTimeout(appArgs); setProperty(TEST_CASE_TIMEOUT_IN_MINUTES_KEY, valueOf(testCaseTimeout)); final boolean shouldValidateDescription = appArgs.shouldValidateDescription(); final boolean shouldValidateCheckstyle = appArgs.shouldValidateCheckstyle(); String runConfigPath = FilenameUtils.normalize(appArgs.getRunConfigPath()); BuildMode buildMode = null; Set<String> changedFiles = null; try { String smartModePath = appArgs.getChangesOnlyConfigPath(); if (StringUtils.isEmpty(smartModePath)) { buildMode = BuildMode.BASIC; changedFiles = new HashSet<>(); printBuildModeInfo(buildMode); } else { buildMode = BuildMode.CHANGED; changedFiles = readChangedFilesFromSource(smartModePath); printBuildModeInfo(buildMode); } } catch (Exception ex) { log.error("Exception: " + ex.getMessage()); System.exit(1); } // Override with the values from the file if configured List<String> testSuitesParallel = new ArrayList<>(); List<String> testSuitesSequential = new ArrayList<>(); BulkRunMode bulkRunMode = runTestsInParallel ? ALL_PARALLEL : ALL_SEQUENTIAL; TestCaseRunMode unspecifiedTestSuiteRunMode = runTestsInParallel ? TestCaseRunMode.PARALLEL : TestCaseRunMode.SEQUENTIAL; if (get(runConfigPath).isAbsolute() && isRegularFile(get(runConfigPath), NOFOLLOW_LINKS) && equalsIgnoreCase(PROPERTIES_FILE_EXTENSION, FilenameUtils.getExtension(runConfigPath))) { Properties runConfigurationProperties = ArgumentProcessorUtils.getPropertiesFromFile(runConfigPath); shouldPrintCoverageData = getBooleanFromPropertiesWithDefault(TEST_COVERAGE, shouldPrintCoverageData, runConfigurationProperties); threadCount = getIntFromPropertiesWithDefaultAndRange(TEST_PARALLEL_THREAD_COUNT, Runtime.getRuntime().availableProcessors(), runConfigurationProperties, 1, MAX_THREADS_TEST_RUNNER + 1); testSuites = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_TO_RUN); testSuitesParallel = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_PARALLEL); testSuitesSequential = getTestSuitesForKey(runConfigurationProperties, TEST_SUITES_SEQUENTIAL); addErrorIfSameTestSuiteIsInBothParallelOrSequential(testSuitesParallel, testSuitesSequential); unspecifiedTestSuiteRunMode = getEnumInstanceFromPropertiesWithDefault(TEST_SUITES_RUN_UNSPECIFIED, unspecifiedTestSuiteRunMode, runConfigurationProperties); addWarningsForMisconfiguredTestSuites(unspecifiedTestSuiteRunMode, testSuites, testSuitesSequential, testSuitesParallel); bulkRunMode = POSSIBLY_MIXED; } else { // Warn when file is misconfigured, relative path, file does not exist or is not a properties file log.info(format(DID_NOT_DETECT_RUN_CONFIGURATION_PROPERTIES_FILE, runConfigPath)); } String testCaseReportLocation = getProperty(TEST_CASE_REPORT_LOCATION); if (StringUtils.isBlank(testCaseReportLocation)) { log.info("Test case report location property [" + TEST_CASE_REPORT_LOCATION + "] is not defined. Report will be skipped."); } // Setting thread count for visibility in ParallelTestCaseExecutorService setProperty(SLANG_TEST_RUNNER_THREAD_COUNT, valueOf(threadCount)); log.info(NEW_LINE + "------------------------------------------------------------"); log.info("Building project: " + projectPath); log.info("Content root is at: " + contentPath); log.info("Test root is at: " + testsPath); log.info("Active test suites are: " + getListForPrint(testSuites)); log.info("Parallel run mode is configured for test suites: " + getListForPrint(testSuitesParallel)); log.info("Sequential run mode is configured for test suites: " + getListForPrint(testSuitesSequential)); log.info("Default run mode '" + unspecifiedTestSuiteRunMode.name().toLowerCase() + "' is configured for test suites: " + getListForPrint( getDefaultRunModeTestSuites(testSuites, testSuitesParallel, testSuitesSequential))); log.info("Bulk run mode for tests: " + getBulkModeForPrint(bulkRunMode)); log.info("Print coverage data: " + valueOf(shouldPrintCoverageData)); log.info("Validate description: " + valueOf(shouldValidateDescription)); log.info("Validate checkstyle: " + valueOf(shouldValidateCheckstyle)); log.info("Thread count: " + threadCount); log.info("Test case timeout in minutes: " + (isEmpty(testCaseTimeout) ? valueOf(MAX_TIME_PER_TESTCASE_IN_MINUTES) : testCaseTimeout)); log.info(NEW_LINE + "Loading..."); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/testRunnerContext.xml"); context.registerShutdownHook(); SlangBuilder slangBuilder = context.getBean(SlangBuilder.class); LoggingService loggingService = context.getBean(LoggingServiceImpl.class); Slang slang = context.getBean(Slang.class); try { updateTestSuiteMappings(context.getBean(TestRunInfoService.class), testSuitesParallel, testSuitesSequential, testSuites, unspecifiedTestSuiteRunMode); registerEventHandlers(slang); List<RuntimeException> exceptions = new ArrayList<>(); SlangBuildResults buildResults = slangBuilder.buildSlangContent(projectPath, contentPath, testsPath, testSuites, shouldValidateDescription, shouldValidateCheckstyle, bulkRunMode, buildMode, changedFiles); exceptions.addAll(buildResults.getCompilationExceptions()); if (exceptions.size() > 0) { logErrors(exceptions, projectPath, loggingService); } IRunTestResults runTestsResults = buildResults.getRunTestsResults(); Map<String, TestRun> skippedTests = runTestsResults.getSkippedTests(); if (isNotEmpty(skippedTests)) { printSkippedTestsSummary(skippedTests, loggingService); } printPassedTests(runTestsResults, loggingService); if (shouldPrintCoverageData) { printTestCoverageData(runTestsResults, loggingService); } if (isNotEmpty(runTestsResults.getFailedTests())) { printBuildFailureSummary(projectPath, runTestsResults, loggingService); } else { printBuildSuccessSummary(contentPath, buildResults, runTestsResults, loggingService); } loggingService.waitForAllLogTasksToFinish(); generateTestCaseReport(context.getBean(SlangTestCaseRunReportGeneratorService.class), runTestsResults, testCaseReportLocation); System.exit(isNotEmpty(runTestsResults.getFailedTests()) ? 1 : 0); } catch (Throwable e) { logErrorsPrefix(loggingService); loggingService.logEvent(Level.ERROR, "Exception: " + e.getMessage()); logErrorsSuffix(projectPath, loggingService); loggingService.waitForAllLogTasksToFinish(); System.exit(1); } }
From source file:com.net2plan.gui.GUINet2Plan.java
/** * <p>Main method</p>// w ww . j a va 2 s . c o m * * @param args Command-line parameters (unused) * @since 0.2.0 */ public static void main(String[] args) { SystemUtils.configureEnvironment(GUINet2Plan.class, UserInterface.GUI); /* Add default canvas systems */ PluginSystem.addPlugin(ITopologyCanvas.class, JUNGCanvas.class); PrintStream stdout = System.out; PrintStream stderr = System.err; try { PrintStream out = new PrintStream(ErrorHandling.STREAM, true, StandardCharsets.UTF_8.name()); System.setOut(out); System.setErr(out); getInstance().start(); } catch (Throwable ex) { System.setOut(stdout); System.setErr(stderr); System.out.println("Error loading the graphic environment. Please, try the command line interface."); if (!(ex instanceof Net2PlanException) || ErrorHandling.isDebugEnabled()) ErrorHandling.printStackTrace(ex); if (ex instanceof Net2PlanException) System.out.println(ex.getMessage()); } }
From source file:com.clustercontrol.agent.Agent.java
/** * ?//w w w . j av a 2 s.c om * * @param args ?? */ public static void main(String[] args) throws Exception { // ? if (args.length != 1) { System.out.println("Usage : java Agent [Agent.properties File Path]"); System.exit(1); } try { // System m_log.info("starting Hinemos Agent..."); m_log.info("java.vm.version = " + System.getProperty("java.vm.version")); m_log.info("java.vm.vendor = " + System.getProperty("java.vm.vendor")); m_log.info("java.home = " + System.getProperty("java.home")); m_log.info("os.name = " + System.getProperty("os.name")); m_log.info("os.arch = " + System.getProperty("os.arch")); m_log.info("os.version = " + System.getProperty("os.version")); m_log.info("user.name = " + System.getProperty("user.name")); m_log.info("user.dir = " + System.getProperty("user.dir")); m_log.info("user.country = " + System.getProperty("user.country")); m_log.info("user.language = " + System.getProperty("user.language")); m_log.info("file.encoding = " + System.getProperty("file.encoding")); // System(SET) String limitKey = "jdk.xml.entityExpansionLimit"; // TODO JRE??????????????????? System.setProperty(limitKey, "0"); m_log.info(limitKey + " = " + System.getProperty(limitKey)); // TODO ???agentHome // ?????????? File file = new File(args[0]); agentHome = file.getParentFile().getParent() + "/"; m_log.info("agentHome=" + agentHome); // long startDate = HinemosTime.currentTimeMillis(); m_log.info("start date = " + new Date(startDate) + "(" + startDate + ")"); agentInfo.setStartupTime(startDate); // Agent?? m_log.info("Agent.properties = " + args[0]); // ? File scriptDir = new File(agentHome + "script/"); if (scriptDir.exists()) { File[] listFiles = scriptDir.listFiles(); if (listFiles != null) { for (File f : listFiles) { boolean ret = f.delete(); if (ret) { m_log.debug("delete script : " + f.getName()); } else { m_log.warn("delete script error : " + f.getName()); } } } else { m_log.warn("listFiles is null"); } } else { //???????? boolean ret = scriptDir.mkdir(); if (!ret) { m_log.warn("mkdir error " + scriptDir.getPath()); } } // queue? m_sendQueue = new SendQueue(); // Agent? Agent agent = new Agent(args[0]); //----------------- //-- //----------------- m_log.debug("exec() : create topic "); m_receiveTopic = new ReceiveTopic(m_sendQueue); m_receiveTopic.setName("ReceiveTopicThread"); m_log.info("receiveTopic start 1"); m_receiveTopic.start(); m_log.info("receiveTopic start 2"); // ? agent.exec(); m_log.info("Hinemos Agent started"); // ? agent.waitAwakeAgent(); } catch (Throwable e) { m_log.error("Agent.java: Runtime Exception Occurred. " + e.getClass().getName() + ", " + e.getMessage(), e); } }
From source file:com.ikanow.aleph2.analytics.spark.assets.SparkJsInterpreterTopology.java
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException { final SetOnce<IBucketLogger> bucket_logger = new SetOnce<>(); final SetOnce<String> job_name = new SetOnce<>(); // (the string we'll use in logging activities) try {//from w ww .j a v a2s . c o m final Tuple2<IAnalyticsContext, Optional<ProcessingTestSpecBean>> aleph2_tuple = SparkTechnologyUtils .initializeAleph2(args); final IAnalyticsContext context = aleph2_tuple._1(); final Optional<ProcessingTestSpecBean> test_spec = aleph2_tuple._2(); bucket_logger.set(context.getLogger(context.getBucket())); job_name.set(context.getJob().map(j -> j.name()).orElse("no_name")); // Optional: make really really sure it exists after the specified timeout SparkTechnologyUtils.registerTestTimeout(test_spec, () -> { System.exit(0); }); final SparkTopologyConfigBean config = BeanTemplateUtils .from(context.getJob().map(job -> job.config()).orElse(Collections.emptyMap()), SparkTopologyConfigBean.class) .get(); final String js_script = Optional.ofNullable(config.script()).orElse(""); //INFO: System.out.println("Starting " + job_name.get()); SparkConf spark_context = new SparkConf().setAppName(job_name.get()); test_spec.ifPresent(spec -> System.out .println("OPTIONS: test_spec = " + BeanTemplateUtils.toJson(spec).toString())); try (final JavaSparkContext jsc = new JavaSparkContext(spark_context)) { final Multimap<String, JavaPairRDD<Object, Tuple2<Long, IBatchRecord>>> inputs = SparkTechnologyUtils .buildBatchSparkInputs(context, test_spec, jsc, Collections.emptySet()); final JavaPairRDD<Object, Tuple2<Long, IBatchRecord>> all_inputs = inputs.values().stream() .reduce((acc1, acc2) -> acc1.union(acc2)).orElse(null); // Load globals: ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); engine.put("_a2_global_context", context); engine.put("_a2_global_bucket", context.getBucket().get()); engine.put("_a2_global_job", context.getJob().get()); engine.put("_a2_global_config", BeanTemplateUtils.configureMapper(Optional.empty()).convertValue(config, JsonNode.class)); engine.put("_a2_global_mapper", BeanTemplateUtils.configureMapper(Optional.empty())); //TODO (until bucket logger is serializable, don't allow anywhere) //engine.put("_a2_bucket_logger", bucket_logger.optional().orElse(null)); engine.put("_a2_enrichment_name", job_name.get()); engine.put("_a2_spark_inputs", inputs); engine.put("_a2_spark_inputs_all", all_inputs); engine.put("_a2_spark_context", jsc); Stream.concat(config.uploaded_lang_files().stream(), Stream.of("aleph2_sparkjs_globals_before.js", "")) .flatMap(Lambdas.flatWrap_i(import_path -> { try { if (import_path.equals("")) { // also import the user script just before here return js_script; } else return IOUtils.toString(SparkJsInterpreterTopology.class.getClassLoader() .getResourceAsStream(import_path), "UTF-8"); } catch (Throwable e) { bucket_logger.optional() .ifPresent(l -> l.log(Level.ERROR, ErrorUtils.lazyBuildMessage(false, () -> SparkJsInterpreterTopology.class.getSimpleName(), () -> job_name.get() + ".main", () -> null, () -> ErrorUtils.get( "Error initializing stage {0} (script {1}): {2}", job_name.get(), import_path, e.getMessage()), () -> ImmutableMap.<String, Object>of("full_error", ErrorUtils.getLongForm("{0}", e))))); System.out.println(ErrorUtils.getLongForm("onStageInitialize: {0}", e)); throw e; // ignored } })).forEach(Lambdas.wrap_consumer_i(script -> { try { engine.eval(script); } catch (Throwable e) { bucket_logger.optional() .ifPresent(l -> l.log(Level.ERROR, ErrorUtils.lazyBuildMessage(false, () -> SparkJsInterpreterTopology.class.getSimpleName(), () -> job_name.get() + ".main", () -> null, () -> ErrorUtils.get( "Error initializing stage {0} (main script): {1}", job_name.get(), e.getMessage()), () -> ImmutableMap.<String, Object>of("full_error", ErrorUtils.getLongForm("{0}", e))))); System.out.println(ErrorUtils.getLongForm("onStageInitialize: {0}", e)); throw e; // ignored } })); ; jsc.stop(); //INFO: System.out.println("Finished " + job_name.get()); } } catch (Throwable t) { System.out.println(ErrorUtils.getLongForm("ERROR: {0}", t)); bucket_logger.optional().ifPresent(l -> l.log(Level.ERROR, ErrorUtils.lazyBuildMessage(false, () -> SparkJsInterpreterTopology.class.getSimpleName() + job_name.optional().map(j -> "." + j).orElse(""), () -> job_name.optional().orElse("global") + ".main", () -> null, () -> ErrorUtils.get("Error on batch in job {0}: {1}", job_name.optional().orElse("global") + ".main", t.getMessage()), () -> ImmutableMap.<String, Object>of("full_error", ErrorUtils.getLongForm("{0}", t))))); } }
From source file:grakn.core.server.Grakn.java
public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler( (Thread t, Throwable e) -> LOG.error(ErrorMessage.UNCAUGHT_EXCEPTION.getMessage(t.getName()), e)); try {/*ww w .ja va 2s. c o m*/ String graknPidFileProperty = Optional.ofNullable(SystemProperty.GRAKN_PID_FILE.value()).orElseThrow( () -> new RuntimeException(ErrorMessage.GRAKN_PIDFILE_SYSTEM_PROPERTY_UNDEFINED.getMessage())); Path pidfile = Paths.get(graknPidFileProperty); PIDManager pidManager = new PIDManager(pidfile); pidManager.trackGraknPid(); // Start Server with timer Stopwatch timer = Stopwatch.createStarted(); boolean benchmark = parseBenchmarkArg(args); Server server = ServerFactory.createServer(benchmark); server.start(); LOG.info("Grakn started in {}", timer.stop()); } catch (RuntimeException | IOException e) { LOG.error(ErrorMessage.UNCAUGHT_EXCEPTION.getMessage(e.getMessage()), e); System.err.println(ErrorMessage.UNCAUGHT_EXCEPTION.getMessage(e.getMessage())); } }
From source file:net.pms.PMS.java
public static void main(String args[]) throws IOException, ConfigurationException { boolean displayProfileChooser = false; // FIXME (breaking change): use a standard argument // format (and a standard argument processor) e.g. // --console, --scrollbars &c. if (args.length > 0) { for (int a = 0; a < args.length; a++) { if (args[a].equals(CONSOLE)) { System.setProperty(CONSOLE, Boolean.toString(true)); } else if (args[a].equals(NATIVELOOK)) { System.setProperty(NATIVELOOK, Boolean.toString(true)); } else if (args[a].equals(SCROLLBARS)) { System.setProperty(SCROLLBARS, Boolean.toString(true)); } else if (args[a].equals(NOCONSOLE)) { System.setProperty(NOCONSOLE, Boolean.toString(true)); } else if (args[a].equals(PROFILES)) { displayProfileChooser = true; }//w w w . j ava 2 s . c o m } } try { Toolkit.getDefaultToolkit(); if (isHeadless()) { if (System.getProperty(NOCONSOLE) == null) { System.setProperty(CONSOLE, Boolean.toString(true)); } } } catch (Throwable t) { System.err.println("Toolkit error: " + t.getClass().getName() + ": " + t.getMessage()); if (System.getProperty(NOCONSOLE) == null) { System.setProperty(CONSOLE, Boolean.toString(true)); } } if (!isHeadless() && displayProfileChooser) { ProfileChooser.display(); } try { setConfiguration(new PmsConfiguration()); assert getConfiguration() != null; // Load the (optional) logback config file. // This has to be called after 'new PmsConfiguration' // as the logging starts immediately and some filters // need the PmsConfiguration. // XXX not sure this is (still) true: the only filter // we use is ch.qos.logback.classic.filter.ThresholdFilter LoggingConfigFileLoader.load(); // create the PMS instance returned by get() createInstance(); // calls new() then init() } catch (Throwable t) { String errorMessage = String.format("Configuration error: %s: %s", t.getClass().getName(), t.getMessage()); System.err.println(errorMessage); t.printStackTrace(); if (!isHeadless() && instance != null) { JOptionPane.showMessageDialog( ((JFrame) (SwingUtilities.getWindowAncestor((Component) instance.getFrame()))), errorMessage, Messages.getString("PMS.42"), JOptionPane.ERROR_MESSAGE); } } }
From source file:com.t3.client.TabletopTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About TabletopTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }//w w w . j a v a 2s.c o m // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); MacroEngine.initialize(); configureJide(); //TODO find out how to not call this twice without destroying error windows final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new T3EventQueue()); // LAF try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); configureJide(); if (WINDOWS) LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); else LookAndFeelFactory.installJideExtension(); if (MAC_OS_X) { macOSXicon(); } menuBar = new AppMenuBar(); } catch (Exception e) { TabletopTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { @Override public void run() { initialize(); EventQueue.invokeLater(new Runnable() { @Override public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { @Override public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }