List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:com.epam.reportportal.auth.AuthServerApplication.java
public static void main(String[] args) { Optional.ofNullable(System.getenv("rp.profiles")) .ifPresent(p -> System.setProperty("spring.profiles.active", p)); SpringApplication.run(AuthServerApplication.class, args); }
From source file:com.googlecode.promnetpp.main.Main.java
/** * Main function (entry point for the tool). * * @param args Command-line arguments./* ww w.j ava2 s .co m*/ */ public static void main(String[] args) { //Prepare logging try { Handler fileHandler = new FileHandler("promnetpp-log.xml"); Logger logger = Logger.getLogger(""); logger.removeHandler(logger.getHandlers()[0]); logger.addHandler(fileHandler); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } String PROMNeTppHome = System.getenv("PROMNETPP_HOME"); if (PROMNeTppHome == null) { String userDir = System.getProperty("user.dir"); System.err.println("WARNING: PROMNETPP_HOME environment variable" + " not set."); System.err.println("PROMNeT++ will assume " + userDir + " as" + " home."); PROMNeTppHome = userDir; } System.setProperty("promnetpp.home", PROMNeTppHome); Logger.getLogger(Main.class.getName()).log(Level.INFO, "PROMNeT++ home" + " set to {0}", System.getProperty("promnetpp.home")); if (args.length == 1) { fileNameOrPath = args[0]; configurationFilePath = PROMNeTppHome + "/default-configuration.xml"; } else if (args.length == 2) { fileNameOrPath = args[0]; configurationFilePath = args[1]; } else { System.err.println("Invalid number of command-line arguments."); System.err.println("Usage #1: promnetpp.jar <PROMELA model>.pml"); System.err.println("Usage #2: promnetpp.jar <PROMELA model>.pml" + " <configuration file>.xml"); System.exit(1); } //We must have a file name or path at this point assert fileNameOrPath != null : "Unspecified file name or" + " path to file!"; //Log basic info Logger.getLogger(Main.class.getName()).log(Level.INFO, "Running" + " PROMNeT++ from {0}", System.getProperty("user.dir")); //Final steps loadXMLFile(); Verifier verifier = new StandardVerifier(fileNameOrPath); verifier.doVerification(); assert verifier.isErrorFree() : "Errors reported during model" + " verification!"; verifier.finish(); buildAbstractSyntaxTree(); Translator translator = new StandardTranslator(); translator.init(); translator.translate(abstractSyntaxTree); translator.finish(); }
From source file:azkaban.jobtype.HadoopSecureSparkWrapper.java
/** * Entry point: a Java wrapper to the spark-submit command * Args is built in HadoopSparkJob.// w w w . ja va 2 s. c o m * * @param args * @throws Exception */ public static void main(final String[] args) throws Exception { Properties jobProps = HadoopSecureWrapperUtils.loadAzkabanProps(); HadoopConfigurationInjector.injectResources(new Props(null, jobProps)); if (HadoopSecureWrapperUtils.shouldProxy(jobProps)) { String tokenFile = System.getenv(HADOOP_TOKEN_FILE_LOCATION); UserGroupInformation proxyUser = HadoopSecureWrapperUtils.setupProxyUser(jobProps, tokenFile, logger); proxyUser.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { runSpark(args); return null; } }); } else { runSpark(args); } }
From source file:com.ebay.jetstream.application.JetstreamApplication.java
/** * Every Jetstream application shares a common main(). It creates the instance of the application, configures command * line options, parses the command line based on the options, starts the application based on the resulting * configuration, and then runs the application. * //from www . ja v a2 s. c o m * @param args * command line arguments */ public static void main(String[] args) throws Exception { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); JetstreamApplication ta = null; try { ta = getInstance(); // Allow JetstreamApplication option handling methods to be protected final JetstreamApplication optionHandler = ta; new CliOptions(new CliOptionHandler() { public Options addOptions(Options options) { return optionHandler.addOptions(options); } public void parseOptions(CommandLine line) { optionHandler.parseOptions(line); } }, args); if (System.getenv("COS") == null) System.setProperty("COS", "Dev"); ta.init(); } catch (Exception e) { LOGGER.error("Failed to start Application" + e.getLocalizedMessage()); System.err.println("Failed to start application: " + e); e.printStackTrace(System.err); System.exit(1); } ta.run(); // this is the container's event loop }
From source file:me.timothy.ddd.DrunkDuckDispatch.java
License:asdf
public static void main(String[] args) throws LWJGLException { try {//from ww w.j a va2 s. c o m float defaultDisplayWidth = SizeScaleSystem.EXPECTED_WIDTH / 2; float defaultDisplayHeight = SizeScaleSystem.EXPECTED_HEIGHT / 2; boolean fullscreen = false, defaultDisplay = !fullscreen; File resolutionInfo = new File("graphics.json"); if (resolutionInfo.exists()) { try (FileReader fr = new FileReader(resolutionInfo)) { JSONObject obj = (JSONObject) new JSONParser().parse(fr); Set<?> keys = obj.keySet(); for (Object o : keys) { if (o instanceof String) { String key = (String) o; switch (key.toLowerCase()) { case "width": defaultDisplayWidth = JSONCompatible.getFloat(obj, key); break; case "height": defaultDisplayHeight = JSONCompatible.getFloat(obj, key); break; case "fullscreen": fullscreen = JSONCompatible.getBoolean(obj, key); defaultDisplay = !fullscreen; break; } } } } catch (IOException | ParseException e) { e.printStackTrace(); } float expHeight = defaultDisplayWidth * (SizeScaleSystem.EXPECTED_HEIGHT / SizeScaleSystem.EXPECTED_WIDTH); float expWidth = defaultDisplayHeight * (SizeScaleSystem.EXPECTED_WIDTH / SizeScaleSystem.EXPECTED_HEIGHT); if (Math.round(defaultDisplayWidth) != Math.round(expWidth)) { if (defaultDisplayHeight < expHeight) { System.err.printf("%f x %f is an invalid resolution; adjusting to %f x %f\n", defaultDisplayWidth, defaultDisplayHeight, defaultDisplayWidth, expHeight); defaultDisplayHeight = expHeight; } else { System.err.printf("%f x %f is an invalid resolution; adjusting to %f x %f\n", defaultDisplayWidth, defaultDisplayHeight, expWidth, defaultDisplayHeight); defaultDisplayWidth = expWidth; } } } File dir = null; String os = getOS(); if (os.equals("windows")) { dir = new File(System.getenv("APPDATA"), "timgames/"); } else { dir = new File(System.getProperty("user.home"), ".timgames/"); } File lwjglDir = new File(dir, "lwjgl-2.9.1/"); Resources.init(); Resources.downloadIfNotExists(lwjglDir, "lwjgl-2.9.1.zip", "http://umad-barnyard.com/lwjgl-2.9.1.zip", "Necessary LWJGL natives couldn't be found, I can attempt " + "to download it, but I make no promises", "Unfortunately I was unable to download it, so I'll open up the " + "link to the official download. Make sure you get LWJGL version 2.9.1, " + "and you put it at " + dir.getAbsolutePath() + "/lwjgl-2.9.1.zip", new Runnable() { @Override public void run() { if (!Desktop.isDesktopSupported()) { JOptionPane.showMessageDialog(null, "I couldn't " + "even do that! Download it manually and try again"); return; } try { Desktop.getDesktop().browse(new URI("http://www.lwjgl.org/download.php")); } catch (IOException | URISyntaxException e) { JOptionPane.showMessageDialog(null, "Oh cmon.. Address is http://www.lwjgl.org/download.php, good luck"); System.exit(1); } } }, 5843626); Resources.extractIfNotFound(lwjglDir, "lwjgl-2.9.1.zip", "lwjgl-2.9.1"); System.setProperty("org.lwjgl.librarypath", new File(dir, "lwjgl-2.9.1/lwjgl-2.9.1/native/" + os).getAbsolutePath()); // deal w/ it System.setProperty("net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath")); Resources.downloadIfNotExists("entities.json", "http://umad-barnyard.com/ddd/entities.json", 16142); Resources.downloadIfNotExists("map.binary", "http://umad-barnyard.com/ddd/map.binary", 16142); Resources.downloadIfNotExists("victory.txt", "http://umad-barnyard.com/ddd/victory.txt", 168); Resources.downloadIfNotExists("failure.txt", "http://umad-barnyard.com/ddd/failure.txt", 321); File resFolder = new File("resources/"); if (!resFolder.exists() && !new File("player-still.png").exists()) { Resources.downloadIfNotExists("resources.zip", "http://umad-barnyard.com/ddd/resources.zip", 54484); Resources.extractIfNotFound(new File("."), "resources.zip", "player-still.png"); new File("resources.zip").delete(); } File soundFolder = new File("sounds/"); if (!soundFolder.exists()) { soundFolder.mkdirs(); Resources.downloadIfNotExists("sounds/sounds.zip", "http://umad-barnyard.com/ddd/sounds.zip", 1984977); Resources.extractIfNotFound(soundFolder, "sounds.zip", "asdfasdffadasdf"); new File(soundFolder, "sounds.zip").delete(); } AppGameContainer appgc; ddd = new DrunkDuckDispatch(); appgc = new AppGameContainer(ddd); appgc.setTargetFrameRate(60); appgc.setShowFPS(false); appgc.setAlwaysRender(true); if (fullscreen) { DisplayMode[] modes = Display.getAvailableDisplayModes(); DisplayMode current, best = null; float ratio = 0f; for (int i = 0; i < modes.length; i++) { current = modes[i]; float rX = (float) current.getWidth() / SizeScaleSystem.EXPECTED_WIDTH; float rY = (float) current.getHeight() / SizeScaleSystem.EXPECTED_HEIGHT; System.out.println(current.getWidth() + "x" + current.getHeight() + " -> " + rX + "x" + rY); if (rX == rY && rX > ratio) { best = current; ratio = rX; } } if (best == null) { System.out.println("Failed to find an appropriately scaled resolution, using default display"); defaultDisplay = true; } else { appgc.setDisplayMode(best.getWidth(), best.getHeight(), true); SizeScaleSystem.setRealHeight(best.getHeight()); SizeScaleSystem.setRealWidth(best.getWidth()); System.out.println("I choose " + best.getWidth() + "x" + best.getHeight()); } } if (defaultDisplay) { SizeScaleSystem.setRealWidth(Math.round(defaultDisplayWidth)); SizeScaleSystem.setRealHeight(Math.round(defaultDisplayHeight)); appgc.setDisplayMode(Math.round(defaultDisplayWidth), Math.round(defaultDisplayHeight), false); } ddd.logger.info( "SizeScaleSystem: " + SizeScaleSystem.getRealWidth() + "x" + SizeScaleSystem.getRealHeight()); appgc.start(); } catch (SlickException ex) { LogManager.getLogger(DrunkDuckDispatch.class.getSimpleName()).catching(Level.ERROR, ex); } }
From source file:PartitionLR.java
public static void main(String[] args) { if (args.length < 6) { System.err.println("Usage: JavaHdfsLR <master> <file> <iters> <L> <D> <use FPGA?> (<testing file>)"); System.exit(1);/*from w w w. j a v a 2s .c o m*/ } int ITERATIONS = Integer.parseInt(args[2]); System.out.println("iterations: " + ITERATIONS); L = Integer.parseInt(args[3]); System.out.println("L: " + L); D = Integer.parseInt(args[4]); System.out.println("D: " + D); useFPGA = Integer.parseInt(args[5]); System.out.println("use FPGA: " + useFPGA); JavaSparkContext sc = new JavaSparkContext(args[0], "PartitionLR", System.getenv("SPARK_HOME"), "target/simple-project-1.0.jar"); JavaRDD<String> lines = sc.textFile(args[1]); JavaRDD<DataPoint> points = lines.map(new ParsePoint()).repartition(32).cache(); float[][] w = new float[L][D]; for (int i = 0; i < L; i++) { for (int j = 0; j < D; j++) { w[i][j] = 0.0f; } } System.out.print("Initial w: "); printWeights(w); for (int k = 1; k <= ITERATIONS; k++) { System.out.println("On iteration " + k); long tic = System.nanoTime(); float[][] gradient = points.mapPartitions(new BackwardLR(w)).reduce(new VectorSum()); System.out.println("elapsed time: " + (System.nanoTime() - tic) / 1e9); for (int i = 0; i < L; i++) { for (int j = 0; j < D; j++) { w[i][j] -= gradient[i][j]; } } } System.out.print("Final w: "); printWeights(w); lines = sc.textFile(args.length < 7 ? args[1] : args[6]); System.out.println("first prediction"); System.out.println(Arrays .toString(lines.map(new ParsePoint()).repartition(32).mapPartitions(new ForwardLR(w)).first())); System.exit(0); }
From source file:com.nextdoor.bender.Bender.java
/** * Main entrypoint for the Bender CLI tool - handles the argument parsing and triggers the * appropriate methods for ultimately invoking a Bender Handler. * * @param args/*from ww w. j a va 2 s. c om*/ * @throws ParseException */ public static void main(String[] args) throws ParseException { /* * Create the various types of options that we support */ Option help = Option.builder("H").longOpt("help").desc("Print this message").build(); Option handler = Option.builder("h").longOpt("handler").hasArg() .desc("Which Event Handler do you want to simulate? \n" + "Your options are: KinesisHandler, S3Handler. \n" + "Default: KinesisHandler") .build(); Option source_file = Option.builder("s").longOpt("source_file").required().hasArg() .desc("Reference to the file that you want to process. Usage depends " + "on the Handler you chose. If you chose KinesisHandler " + "then this is a local file (file://path/to/file). If you chose " + "S3Handler, then this is the path to the file in S3 that you want to process " + "(s3://bucket/file...)") .build(); Option kinesis_stream_name = Option.builder().longOpt("kinesis_stream_name").hasArg() .desc("What stream name should we mimic? " + "Default: " + KINESIS_STREAM_NAME + " (Kinesis Handler Only)") .build(); /* * Build out the option handler and parse the options */ Options options = new Options(); options.addOption(help); options.addOption(handler); options.addOption(kinesis_stream_name); options.addOption(source_file); /* * Prepare our help formatter */ HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(100); formatter.setSyntaxPrefix("usage: BENDER_CONFIG=file://config.yaml java -jar"); /* * Parse the options themselves. Throw an error and help if necessary. */ CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (UnrecognizedOptionException | MissingOptionException | MissingArgumentException e) { logger.error(e.getMessage()); formatter.printHelp(name, options); System.exit(1); } /* * The CLI tool doesn't have any configuration files built into it. We require that the user set * BENDER_CONFIG to something reasonable. */ if (System.getenv("BENDER_CONFIG") == null) { logger.error("You must set the BENDER_CONFIG environment variable. \n" + "Valid options include: file://<file>"); formatter.printHelp(name, options); System.exit(1); } if (cmd.hasOption("help")) { formatter.printHelp(name, options); System.exit(0); } /* * Depending on the desired Handler, we invoke a specific method and pass in the options (or * defaults) required for that handler. */ String handler_value = cmd.getOptionValue(handler.getLongOpt(), KINESIS); try { switch (handler_value.toLowerCase()) { case KINESIS: invokeKinesisHandler(cmd.getOptionValue(kinesis_stream_name.getLongOpt(), KINESIS_STREAM_NAME), cmd.getOptionValue(source_file.getLongOpt())); break; case S3: invokeS3Handler(cmd.getOptionValue(source_file.getLongOpt())); break; /* * Error out if an invalid handler was supplied. */ default: logger.error("Invalid Handler Option (" + handler_value + "), valid options are: " + KINESIS); formatter.printHelp(name, options); System.exit(1); } } catch (HandlerException e) { logger.error("Error executing handler: " + e); System.exit(1); } }
From source file:org.kafka.log.writer.producer.KafkaLogProducer.java
public static void main(String args[]) { try {//from ww w .j a v a2s . c o m CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption("kT", "kafkaTopic", true, "topic for the kafka server"); options.addOption("mess", "message", true, "message to be passed"); CommandLine line = parser.parse(options, args); String topic = "test"; String message = "data"; if (line.hasOption("kT")) { topic = line.getOptionValue("kT"); } if (line.hasOption("mess")) { message = line.getOptionValue("mess"); } KafkaLogProducer kafkaLogProducer = new KafkaLogProducer(); String kafkaIp = System.getenv("INSIGHTS_KAFKA_AGGREGATOR_PRODUCER_IP"); String kafkaPort = System.getenv("INSIGHTS_KAFKA_ZK_PORT"); String kafkaProducerType = System.getenv("INSIGHTS_KAFKA_PRODUCER_TYPE"); // kafkaIp, String port, String topic, String producerType KafkaLogProducer producer = new KafkaLogProducer(kafkaIp, kafkaPort, topic, kafkaProducerType); producer.sendEventLog(message); } catch (Exception e) { e.printStackTrace(); } }
From source file:au.com.jwatmuff.eventmanager.Main.java
/** * Main method.//w w w. j a va 2 s. c o m */ public static void main(String args[]) { LogUtils.setupUncaughtExceptionHandler(); /* Set timeout for RMI connections - TODO: move to external file */ System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", "2000"); updateRmiHostName(); /* * Set up menu bar for Mac */ System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Event Manager"); /* * Set look and feel to 'system' style */ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { log.info("Failed to set system look and feel"); } /* * Set workingDir to a writable folder for storing competitions, settings etc. */ String applicationData = System.getenv("APPDATA"); if (applicationData != null) { workingDir = new File(applicationData, "EventManager"); if (workingDir.exists() || workingDir.mkdirs()) { // redirect logging to writable folder LogUtils.reconfigureFileAppenders("log4j.properties", workingDir); } else { workingDir = new File("."); } } // log version for debugging log.info("Running version: " + VISIBLE_VERSION + " (Internal: " + VERSION + ")"); /* * Copy license if necessary */ File license1 = new File("license.lic"); File license2 = new File(workingDir, "license.lic"); if (license1.exists() && !license2.exists()) { try { FileUtils.copyFile(license1, license2); } catch (IOException e) { log.warn("Failed to copy license from " + license1 + " to " + license2, e); } } if (license1.exists() && license2.exists()) { if (license1.lastModified() > license2.lastModified()) { try { FileUtils.copyFile(license1, license2); } catch (IOException e) { log.warn("Failed to copy license from " + license1 + " to " + license2, e); } } } /* * Check if run lock exists, if so ask user if it is ok to continue */ if (!obtainRunLock(false)) { int response = JOptionPane.showConfirmDialog(null, "Unable to obtain run-lock.\nPlease ensure that no other instances of EventManager are running before continuing.\nDo you wish to continue?", "Run-lock detected", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) obtainRunLock(true); else System.exit(0); } try { LoadWindow loadWindow = new LoadWindow(); loadWindow.setVisible(true); loadWindow.addMessage("Reading settings.."); /* * Read properties from file */ final Properties props = new Properties(); try { Properties defaultProps = PropertiesLoaderUtils .loadProperties(new ClassPathResource("eventmanager.properties")); props.putAll(defaultProps); } catch (IOException ex) { log.error(ex); } props.putAll(System.getProperties()); File databaseStore = new File(workingDir, "comps"); int rmiPort = Integer.parseInt(props.getProperty("eventmanager.rmi.port")); loadWindow.addMessage("Loading Peer Manager.."); log.info("Loading Peer Manager"); ManualDiscoveryService manualDiscoveryService = new ManualDiscoveryService(); JmDNSRMIPeerManager peerManager = new JmDNSRMIPeerManager(rmiPort, new File(workingDir, "peerid.dat")); peerManager.addDiscoveryService(manualDiscoveryService); monitorNetworkInterfaceChanges(peerManager); loadWindow.addMessage("Loading Database Manager.."); log.info("Loading Database Manager"); DatabaseManager databaseManager = new SQLiteDatabaseManager(databaseStore, peerManager); LicenseManager licenseManager = new LicenseManager(workingDir); loadWindow.addMessage("Loading Load Competition Dialog.."); log.info("Loading Load Competition Dialog"); LoadCompetitionWindow loadCompetitionWindow = new LoadCompetitionWindow(databaseManager, licenseManager, peerManager); loadCompetitionWindow.setTitle(WINDOW_TITLE); loadWindow.dispose(); log.info("Starting Load Competition Dialog"); while (true) { // reset permission checker to use our license licenseManager.updatePermissionChecker(); GUIUtils.runModalJFrame(loadCompetitionWindow); if (loadCompetitionWindow.getSuccess()) { DatabaseInfo info = loadCompetitionWindow.getSelectedDatabaseInfo(); if (!databaseManager.checkLock(info.id)) { String message = "EventManager did not shut down correctly the last time this competition was open. To avoid potential data corruption, you are advised to take the following steps:\n" + "1) Do NOT open this competition\n" + "2) Create a backup of this competition\n" + "3) Delete the competition from this computer\n" + "4) If possible, reload this competition from another computer on the network\n" + "5) Alternatively, you may manually load the backup onto all computers on the network, ensuring the 'Preserve competition ID' option is checked."; String title = "WARNING: Potential Data Corruption Detected"; int status = JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new Object[] { "Cancel (recommended)", "Open anyway" }, "Cancel (recommended)"); if (status == 0) continue; // return to load competition window } SynchronizingWindow syncWindow = new SynchronizingWindow(); syncWindow.setVisible(true); long t = System.nanoTime(); DistributedDatabase database = databaseManager.activateDatabase(info.id, info.passwordHash); long dt = System.nanoTime() - t; log.debug(String.format("Initial sync in %dms", TimeUnit.MILLISECONDS.convert(dt, TimeUnit.NANOSECONDS))); syncWindow.dispose(); if (loadCompetitionWindow.isNewDatabase()) { GregorianCalendar calendar = new GregorianCalendar(); Date today = calendar.getTime(); calendar.set(Calendar.MONTH, Calendar.DECEMBER); calendar.set(Calendar.DAY_OF_MONTH, 31); Date endOfYear = new java.sql.Date(calendar.getTimeInMillis()); CompetitionInfo ci = new CompetitionInfo(); ci.setName(info.name); ci.setStartDate(today); ci.setEndDate(today); ci.setAgeThresholdDate(endOfYear); //ci.setPasswordHash(info.passwordHash); License license = licenseManager.getLicense(); if (license != null) { ci.setLicenseName(license.getName()); ci.setLicenseType(license.getType().toString()); ci.setLicenseContact(license.getContactPhoneNumber()); } database.add(ci); } // Set PermissionChecker to use database's license type String competitionLicenseType = database.get(CompetitionInfo.class, null).getLicenseType(); PermissionChecker.setLicenseType(LicenseType.valueOf(competitionLicenseType)); TransactionNotifier notifier = new TransactionNotifier(); database.setListener(notifier); MainWindow mainWindow = new MainWindow(); mainWindow.setDatabase(database); mainWindow.setNotifier(notifier); mainWindow.setPeerManager(peerManager); mainWindow.setLicenseManager(licenseManager); mainWindow.setManualDiscoveryService(manualDiscoveryService); mainWindow.setTitle(WINDOW_TITLE); mainWindow.afterPropertiesSet(); TestUtil.setActivatedDatabase(database); // show main window (modally) GUIUtils.runModalJFrame(mainWindow); // shutdown procedures // System.exit(); database.shutdown(); databaseManager.deactivateDatabase(1500); if (mainWindow.getDeleteOnExit()) { for (File file : info.localDirectory.listFiles()) if (!file.isDirectory()) file.delete(); info.localDirectory.deleteOnExit(); } } else { // This can cause an RuntimeException - Peer is disconnected peerManager.stop(); System.exit(0); } } } catch (Throwable e) { log.error("Error in main function", e); String message = e.getMessage(); if (message == null) message = ""; if (message.length() > 100) message = message.substring(0, 97) + "..."; GUIUtils.displayError(null, "An unexpected error has occured.\n\n" + e.getClass().getSimpleName() + "\n" + message); System.exit(0); } }
From source file:cc.kune.kunecli.KuneCliMain.java
/** * The main method./*w ww. j av a 2 s .com*/ * * @param args * the arguments * @throws InvalidSyntaxException * the invalid syntax exception * @throws ExecutionException * the execution exception * @throws MalformedURLException * the malformed url exception */ public static void main(final String[] args) throws InvalidSyntaxException, ExecutionException, MalformedURLException { final String serverPrefix = System.getenv("KUNE_SERVER_URL"); if (serverPrefix != null) { SERVER_PREFFIX = serverPrefix; SERVICE_PREFFIX = setServicePrefix(); LOG.debug("Using server URL: " + SERVER_PREFFIX); LOG.debug("Using service URL: " + SERVICE_PREFFIX); } initServices(); // TODO: integrate jline or similar? // http://jline.sourceforge.net/index.html // http://sourceforge.net/projects/javacurses/ // http://massapi.com/class/jcurses/widgets/Button.java.html // Create an empty command set final Set<Command> cs = new LinkedHashSet<Command>(); // Create the interpreter final NaturalCLI nc = new NaturalCLI(cs); // Add the commands that can be understood cs.add(new HelpCommand(cs)); // help cs.add(new HTMLHelpCommand(cs)); // htmlhelp // A script can be useful for kune cs.add(new ExecuteFileCommand(nc)); // execute file <filename:string> // cs.add(new HelloWorldCommand()); // kune specific commands cs.add(injector.getInstance(AuthCommand.class)); cs.add(injector.getInstance(SiteInviteCommand.class)); cs.add(injector.getInstance(SiteI18nStatsCommand.class)); cs.add(injector.getInstance(SiteReindexCommand.class)); cs.add(injector.getInstance(SiteReloadPropertiesCommand.class)); cs.add(injector.getInstance(GroupsCount.class)); cs.add(injector.getInstance(GroupsReindexCommand.class)); cs.add(injector.getInstance(UsersCount.class)); cs.add(injector.getInstance(UsersDailySignInsCommand.class)); cs.add(injector.getInstance(UsersLastSignInsCommand.class)); cs.add(injector.getInstance(UsersLangStatsCommand.class)); cs.add(injector.getInstance(UsersSignInsStatsCommand.class)); cs.add(injector.getInstance(UsersReindexCommand.class)); cs.add(injector.getInstance(WaveToDirCommand.class)); cs.add(injector.getInstance(DeltaMigrationToMongoCommand.class)); // As the return type of these commands are not java.io.Serializable (and // instead GWT's IsSerializable) the return part of this cmds fails // cs.add(injector.getInstance(GetInitDataCommand.class)); // cs.add(injector.getInstance(GetI18nLangCommand.class)); // Execute the command line nc.execute(args, 0); }