List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.funambol.lanciadelta.LanciaDeltaShell.java
public static void main(String[] args) throws Exception { LanciaDeltaShell shell = null;//from ww w .ja v a 2 s .com try { shell = new LanciaDeltaShell(); shell.execute(); } catch (Exception e) { System.err.println(e.getMessage()); if (System.getProperty(PROPERTY_DEBUG) != null) { e.printStackTrace(); } System.exit(1); } }
From source file:elasticityRestinterface.RestInterfaceTester.java
public static void main(String[] args) throws IOException, InterruptedException { // if (args.length != 1) { // printUsage(); // // } Logger log = Logger.getLogger(RestInterface.class); System.out.println("Testing Elasticity Engine Using REST interface "); System.out.println("One instance per 100 users expected, starting at 1"); RestInterface resteEngine = new RestInterface("optimis-ipvm2.ds.cs.umu.se"); String manifest = Util.getManifest("ServManifestY3.xml"); String serviceID = "Testing"; String sp = "optimis-spvm2.ds.cs.umu.se"; boolean LowRiskMode; if ("true".equals(System.getProperty("lowrisk"))) { System.out.println("USING Low Risk Mode"); LowRiskMode = true;//from w w w . ja v a 2 s . co m } else { System.out.println("USING Low cost Mode"); LowRiskMode = false; } resteEngine.startElasticity(serviceID, manifest, LowRiskMode, sp); resteEngine.setMode(serviceID, true); resteEngine.setMode(serviceID, false); // System.out.println(resteEngine.getHtml()); resteEngine.stopElasticity(serviceID); //Call a test-specific method which only returns when we got the -2 recommendation, and the test should then be done. System.out.println("\nTest done, exiting"); Thread.sleep(500); }
From source file:com.cloudera.impala.testutil.SentryServicePinger.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { // Parse command line options to get config file path. Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("config_file") .withDescription("Absolute path to a sentry-site.xml config file (string)").hasArg() .withArgName("CONFIG_FILE").isRequired().create('c')); options.addOption(OptionBuilder.withLongOpt("num_pings") .withDescription("Max number of pings to try before failing (int)").hasArg().isRequired() .withArgName("NUM_PINGS").create('n')); options.addOption(//ww w. j ava 2 s . c o m OptionBuilder.withLongOpt("sleep_secs").withDescription("Time (s) to sleep between pings (int)") .hasArg().withArgName("SLEEP_SECS").create('s')); BasicParser optionParser = new BasicParser(); CommandLine cmdArgs = optionParser.parse(options, args); SentryConfig sentryConfig = new SentryConfig(cmdArgs.getOptionValue("config_file")); int numPings = Integer.parseInt(cmdArgs.getOptionValue("num_pings")); int maxPings = numPings; int sleepSecs = Integer.parseInt(cmdArgs.getOptionValue("sleep_secs")); sentryConfig.loadConfig(); while (numPings > 0) { SentryPolicyService policyService = new SentryPolicyService(sentryConfig); try { policyService.listAllRoles(new User(System.getProperty("user.name"))); LOG.info("Sentry Service ping succeeded."); System.exit(0); } catch (Exception e) { LOG.error(String.format("Error issing RPC to Sentry Service (attempt %d/%d): ", maxPings - numPings + 1, maxPings), e); Thread.sleep(sleepSecs * 1000); } --numPings; } System.exit(1); }
From source file:com.googlecode.promnetpp.main.Main.java
/** * Main function (entry point for the tool). * * @param args Command-line arguments./*from w w w . j a va 2 s . c o 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:de.moritzrupp.stockreader.Main.java
/** * main// ww w. j a v a 2s . c om * @param args */ public static void main(String[] args) { initOptions(); clParser = new GnuParser(); if (args.length == 0) { // if no arguments formatter.printHelp("stockreader", header, options, footer); System.exit(1); } try { CommandLine line = clParser.parse(options, args); if (line.hasOption("h")) { printHelp(); } if (line.hasOption("v")) { System.out.println("stockreader version " + VERSION + ". Copyright 2013 by Moritz Rupp. All rights reserved.\n" + "This application is licensed under The MIT License (MIT). See https://github.com/moritzrupp/stockreader/blob/master/LICENSE.md"); System.exit(0); } if (line.hasOption("p")) { priceArg = true; } if (line.hasOption("f")) { fileArg = true; theFile = new File(line.getOptionValue("f")); } host = line.getOptionValue("host"); username = line.getOptionValue("user"); passwd = line.getOptionValue("password"); from = line.getOptionValue("from"); to = line.getOptionValue("to"); } catch (ParseException exp) { // TODO Auto-generated catch block exp.printStackTrace(); } try { reader = new StockReader(';', new StockQuote(), "UTF-8", (fileArg) ? theFile.toString() : new File(".").getCanonicalPath() + ((System.getProperty("os.name").toLowerCase().startsWith("win")) ? "\\" : "/") + "stocks.csv"); for (int i = 0; i < args.length; i++) { switch (args[i].charAt(0)) { case '-': if (args[i].length() < 2) { System.err.println("Not a valid argument: " + args[i]); printHelp(); System.exit(1); } if (args[i].charAt(1) == 'f' || (args[i].charAt(1) == '-' && args[i].charAt(2) == 'f')) { // get the path and set it to "nosymbol" args[i + 1] = "nosymbol"; } break; default: if (!args[i].equals("nosymbol")) { reader.addSymbol(args[i]); } break; } } reader.getQuotes(); reader.writeToCSV(priceArg); reader.sendmail(from, to, "Aktienkurse", host, username, passwd); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.jbrisbin.groovy.mqdsl.RabbitMQDsl.java
public static void main(String[] argv) { // Parse command line arguments CommandLine args = null;//from w w w. ja v a 2 s. c o m try { Parser p = new BasicParser(); args = p.parse(cliOpts, argv); } catch (ParseException e) { log.error(e.getMessage(), e); } // Check for help if (args.hasOption('?')) { printUsage(); return; } // Runtime properties Properties props = System.getProperties(); // Check for ~/.rabbitmqrc File userSettings = new File(System.getProperty("user.home"), ".rabbitmqrc"); if (userSettings.exists()) { try { props.load(new FileInputStream(userSettings)); } catch (IOException e) { log.error(e.getMessage(), e); } } // Load Groovy builder file StringBuffer script = new StringBuffer(); BufferedInputStream in = null; String filename = "<STDIN>"; if (args.hasOption("f")) { filename = args.getOptionValue("f"); try { in = new BufferedInputStream(new FileInputStream(filename)); } catch (FileNotFoundException e) { log.error(e.getMessage(), e); } } else { in = new BufferedInputStream(System.in); } // Read script if (null != in) { byte[] buff = new byte[4096]; try { for (int read = in.read(buff); read > -1;) { script.append(new String(buff, 0, read)); read = in.read(buff); } } catch (IOException e) { log.error(e.getMessage(), e); } } else { System.err.println("No script file to evaluate..."); } PrintStream stdout = System.out; PrintStream out = null; if (args.hasOption("o")) { try { out = new PrintStream(new FileOutputStream(args.getOptionValue("o")), true); System.setOut(out); } catch (FileNotFoundException e) { log.error(e.getMessage(), e); } } String[] includes = (System.getenv().containsKey("MQDSL_INCLUDE") ? System.getenv("MQDSL_INCLUDE").split(String.valueOf(File.pathSeparatorChar)) : new String[] { System.getenv("HOME") + File.separator + ".mqdsl.d" }); try { // Setup RabbitMQ String username = (args.hasOption("U") ? args.getOptionValue("U") : props.getProperty("mq.user", "guest")); String password = (args.hasOption("P") ? args.getOptionValue("P") : props.getProperty("mq.password", "guest")); String virtualHost = (args.hasOption("v") ? args.getOptionValue("v") : props.getProperty("mq.virtualhost", "/")); String host = (args.hasOption("h") ? args.getOptionValue("h") : props.getProperty("mq.host", "localhost")); int port = Integer.parseInt( args.hasOption("p") ? args.getOptionValue("p") : props.getProperty("mq.port", "5672")); CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host); connectionFactory.setPort(port); connectionFactory.setUsername(username); connectionFactory.setPassword(password); if (null != virtualHost) { connectionFactory.setVirtualHost(virtualHost); } // The DSL builder RabbitMQBuilder builder = new RabbitMQBuilder(); builder.setConnectionFactory(connectionFactory); // Our execution environment Binding binding = new Binding(args.getArgs()); binding.setVariable("mq", builder); String fileBaseName = filename.replaceAll("\\.groovy$", ""); binding.setVariable("log", LoggerFactory.getLogger(fileBaseName.substring(fileBaseName.lastIndexOf("/") + 1))); if (null != out) { binding.setVariable("out", out); } // Include helper files GroovyShell shell = new GroovyShell(binding); for (String inc : includes) { File f = new File(inc); if (f.isDirectory()) { File[] files = f.listFiles(new FilenameFilter() { @Override public boolean accept(File file, String s) { return s.endsWith(".groovy"); } }); for (File incFile : files) { run(incFile, shell, binding); } } else { run(f, shell, binding); } } run(script.toString(), shell, binding); while (builder.isActive()) { try { Thread.sleep(500); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } if (null != out) { out.close(); System.setOut(stdout); } } finally { System.exit(0); } }
From source file:io.apiman.test.common.echo.EchoServer.java
public static void main(String[] args) throws Exception { int port = NumberUtils.toInt(System.getProperty("io.apiman.test.common.echo.port"), 9999); //$NON-NLS-1$ new EchoServer(port).start().join(); }
From source file:io.tempra.AppServer.java
public static void main(String[] args) throws Exception { try {/*from w ww .j a va 2 s . c om*/ // String dir = getProperty("storageLocal");// // System.getProperty("user.home"); String arch = "Win" + System.getProperty("sun.arch.data.model"); System.out.println("sun.arch.data.model " + arch); // Sample to force java load dll or so on a filesystem // InputStream in = AppServer.class.getResourceAsStream("/dll/" + // arch + "/RechargeRPC.dll"); // // File jCliSiTefI = new File(dir + "/" + "RechargeRPC.dll"); // System.out.println("Writing dll to: " + // jCliSiTefI.getAbsolutePath()); // OutputStream os = new FileOutputStream(jCliSiTefI); // byte[] buffer = new byte[4096]; // int length; // while ((length = in.read(buffer)) > 0) { // os.write(buffer, 0, length); // } // os.close(); // in.close(); // System.load(jCliSiTefI.toString()); // addLibraryPath(dir); } catch (Exception e) { e.printStackTrace(); } ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); Server jettyServer = new Server(Integer.parseInt(getProperty("localport"))); // security configuration // FilterHolder holder = new FilterHolder(CrossOriginFilter.class); // holder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, // "*"); // holder.setInitParameter("allowCredentials", "true"); // holder.setInitParameter( // CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); // holder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, // "GET,POST,HEAD"); // holder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, // "X-Requested-With,Content-Type,Accept,Origin"); // holder.setName("cross-origin"); // context.addFilter(holder, fm); ResourceHandler resource_handler = new ResourceHandler(); // add application on embedded server boolean servApp = true; boolean quioskMode = false; // if (System.getProperty("noServApp") != null ) // if (System.getProperty("noServApp").equalsIgnoreCase("true")) // servApp = false; if (servApp) { // ProtectionDomain domain = AppServer.class.getProtectionDomain(); String webDir = AppServer.class.getResource("/webapp").toExternalForm(); System.out.println("Jetty WEB DIR >>>>" + webDir); resource_handler.setDirectoriesListed(true); resource_handler.setWelcomeFiles(new String[] { "index.html" }); resource_handler.setResourceBase(webDir); // // "C:/git/tsAgenciaVirtual/www/"); // resource_handler.setResourceBase("C:/git/tsAgenciaVirtual/www/"); // copyJarResourceToFolder((JarURLConnection) AppServer.class // .getResource("/app").openConnection(), createTempDir("app")); // resource_handler.setResourceBase(System // .getProperty("java.io.tmpdir") + "/app"); } // sample to add rest services on container context.addServlet(FileUploadServlet.class, "/upload"); ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/services/*"); jerseyServlet.setInitOrder(0); jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", RestServices.class.getCanonicalName() + "," + RestServices.class.getCanonicalName()); HandlerList handlers = new HandlerList(); // context.addFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST)); handlers.setHandlers(new Handler[] { resource_handler, context, // wscontext, new DefaultHandler() }); jettyServer.setHandler(handlers); try { // Initialize javax.websocket layer ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(context); wscontainer.setDefaultMaxSessionIdleTimeout(TimeUnit.HOURS.toMillis(1000)); // Add WebSocket endpoint to javax.websocket layer wscontainer.addEndpoint(FileUpload.class); } catch (Throwable t) { t.printStackTrace(System.err); } // try { jettyServer.start(); jettyServer.dump(System.err); if (servApp && quioskMode) { try { Process process = new ProcessBuilder( "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "--kiosk", "--kiosk-printing", "--auto", "--disable-pinch", "--incognito", "--disable-session-crashed-bubble", "--overscroll-history-navigation=0", "http://localhost:" + getProperty("localport")).start(); // Process process = // Runtime.getRuntime().exec(" -kiosk http://localhost:8080"); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; System.out.printf("Output of running %s is:", Arrays.toString(args)); while ((line = br.readLine()) != null) { System.out.println(line); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } // } finally { // jettyServer.destroy(); // }//} jettyServer.join(); }
From source file:org.atomspace.pi2c.runtime.Server.java
public static void main(String[] args) throws Exception { System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("::: ------------------------------ STARTING ------------------------------:::"); System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("\n::: SYSTEM-Properties: :::"); Set<?> properties = System.getProperties().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getProperty(object.toString())); }//from w w w.j av a2s . c o m System.err.println("\n::: ENV-Properties: :::"); properties = System.getenv().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getenv(object.toString())); } windows = System.getProperty("os.name").toLowerCase().startsWith("windows"); linux = System.getProperty("os.name").toLowerCase().startsWith("linux"); sunos = System.getProperty("os.name").toLowerCase().startsWith("sun"); freebsd = System.getProperty("os.name").toLowerCase().startsWith("freebsd"); if (linux || sunos) { //USR2-Signal-Handel lookup internal Server STATUS for Linux or SunOS System.err.println("::: " + new Date() + "::: run unter Linux or SunOS :::"); addUnixSignalStatusHandle(); } else if (freebsd) { System.err.println("::: " + new Date() + "::: run unter FreeBSD :::"); } else if (windows) { //Gracefull Shutdown JFrame for Windows, because can not kill -15 <pid> on Window or in Eclipse Console System.err.println("::: " + new Date() + " ::: run unter windows :::"); addWindowsShutdownHandle(); } else { System.err.println("UNKNOWN OS:" + System.getProperty("os.name")); } status = STATUS_STARTING; Server server = new Server(); Thread serverThread = new Thread(server); serverThread.start(); //Thread can stop by Shutdown-Hook while (true) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); break; } } }
From source file:com.blackboard.WebdavBulkDeleterClient.java
public static void main(String[] args) { if (System.getProperty("log4j.configuration") != null) { PropertyConfigurator.configure(System.getProperty("log4j.configuration")); } else {/*from ww w . ja va2s . c o m*/ BasicConfigurator.configure(); } // Perform command line parsing in an as friendly was as possible. // Could be improved CommandLineParser parser = new PosixParser(); Options options = new Options(); // Use a map to store our options and loop over it to check and parse options via // addAllOptions() and verifyOptions() below Map<String, String> optionsAvailable = new HashMap<String, String>(); optionsAvailable.put("deletion-list", "The file containing the list of courses to delete"); optionsAvailable.put("user", "User with deletion privileges, usually bbsupport"); optionsAvailable.put("password", "Password - ensure you escape any shell characters"); optionsAvailable.put("url", "The Learn URL - usually https://example.com/bbcswebdav/courses"); options = addAllOptions(options, optionsAvailable); options.addOption(OptionBuilder.withLongOpt("no-verify-ssl").withDescription("Don't verify SSL") .hasArg(false).create()); CommandLine line = null; try { line = parser.parse(options, args); verifyOptions(line, optionsAvailable); } catch (ParseException e) { // Detailed reason will be printed by verifyOptions above logger.fatal("Incorrect options specified, exiting..."); System.exit(1); } Scanner scanner = null; try { scanner = new Scanner(new File(line.getOptionValue("deletion-list"))); } catch (FileNotFoundException e) { logger.fatal("Cannot open file : " + e.getLocalizedMessage()); System.exit(1); } // By default we verify SSL certs boolean verifyCertStatus = true; if (line.hasOption("no-verify-ssl")) { verifyCertStatus = false; } // Loop through deletion list and delete courses if they exist. LearnServer instance; try { logger.debug("Attempting to open connection"); instance = new LearnServer(line.getOptionValue("user"), line.getOptionValue("password"), line.getOptionValue("url"), verifyCertStatus); String currentCourse = null; logger.debug("Connection open"); while (scanner.hasNextLine()) { currentCourse = scanner.nextLine(); if (instance.exists(currentCourse)) { try { instance.deleteCourse(currentCourse); logger.info("Processing " + currentCourse + " : Result - Deletion Successful"); } catch (IOException ioe) { logger.error("Processing " + currentCourse + " : Result - Could not Delete (" + ioe.getLocalizedMessage() + ")"); } } else { logger.info("Processing " + currentCourse + " : Result - Course does not exist"); } } } catch (IllegalArgumentException e) { logger.fatal(e.getLocalizedMessage()); System.exit(1); } catch (IOException ioe) { logger.debug(ioe); logger.fatal(ioe.getMessage()); } }