List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.hpe.nv.samples.basic.BasicAnalyzeNVTransactions.java
public static void main(String[] args) { try {//from w w w . j a va2s .com // program arguments Options options = new Options(); options.addOption("i", "server-ip", true, "[mandatory] NV Test Manager IP"); options.addOption("o", "server-port", true, "[mandatory] NV Test Manager port"); options.addOption("u", "username", true, "[mandatory] NV username"); options.addOption("w", "password", true, "[mandatory] NV password"); options.addOption("e", "ssl", true, "[optional] Pass true to use SSL. Default: false"); options.addOption("y", "proxy", true, "[optional] Proxy server host:port"); options.addOption("z", "zip-result-file-path", true, "[optional] File path to store the analysis results as a .zip file"); options.addOption("k", "analysis-ports", true, "[optional] A comma-separated list of ports for test analysis"); options.addOption("b", "browser", true, "[optional] The browser for which the Selenium WebDriver is built. Possible values: Chrome and Firefox. Default: Firefox"); options.addOption("d", "debug", true, "[optional] Pass true to view console debug messages during execution. Default: false"); options.addOption("h", "help", false, "[optional] Generates and prints help information"); // parse and validate the command line arguments CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); if (line.hasOption("help")) { // print help if help argument is passed HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("BasicAnalyzeNVTransactions.java", options); return; } if (line.hasOption("server-ip")) { serverIp = line.getOptionValue("server-ip"); if (serverIp.equals("0.0.0.0")) { throw new Exception( "Please replace the server IP argument value (0.0.0.0) with your NV Test Manager IP"); } } else { throw new Exception("Missing argument -i/--server-ip <serverIp>"); } if (line.hasOption("server-port")) { serverPort = Integer.parseInt(line.getOptionValue("server-port")); } else { throw new Exception("Missing argument -o/--server-port <serverPort>"); } if (line.hasOption("username")) { username = line.getOptionValue("username"); } else { throw new Exception("Missing argument -u/--username <username>"); } if (line.hasOption("password")) { password = line.getOptionValue("password"); } else { throw new Exception("Missing argument -w/--password <password>"); } if (line.hasOption("ssl")) { ssl = Boolean.parseBoolean(line.getOptionValue("ssl")); } if (line.hasOption("zip-result-file-path")) { zipResultFilePath = line.getOptionValue("zip-result-file-path"); } if (line.hasOption("proxy")) { proxySetting = line.getOptionValue("proxy"); } if (line.hasOption("analysis-ports")) { String analysisPortsStr = line.getOptionValue("analysis-ports"); analysisPorts = analysisPortsStr.split(","); } else { analysisPorts = new String[] { "80", "8080" }; } if (line.hasOption("browser")) { browser = line.getOptionValue("browser"); } else { browser = "Firefox"; } if (line.hasOption("debug")) { debug = Boolean.parseBoolean(line.getOptionValue("debug")); } String newLine = System.getProperty("line.separator"); String testDescription = "*** This sample demonstrates how to run transactions as part of an NV test. ***" + newLine + "*** ***" + newLine + "*** In this sample, the NV test starts with the \"3G Busy\" network scenario, running three transactions (see below). ***" + newLine + "*** After the sample stops and analyzes the NV test, it prints the analysis .zip file path to the console. ***" + newLine + "*** ***" + newLine + "*** This sample runs three NV transactions: ***" + newLine + "*** 1. \"Home Page\" transaction: Navigates to the home page in the HPE Network Virtualization website ***" + newLine + "*** 2. \"Get Started\" transaction: Navigates to the Get Started Now page in the HPE Network Virtualization website ***" + newLine + "*** 3. \"Overview\" transaction: Navigates back to the home page in the HPE Network Virtualization website ***" + newLine + "*** ***" + newLine + "*** You can view the actual steps of this sample in the BasicAnalyzeNVTransactions.java file. ***" + newLine; // print the sample's description System.out.println(testDescription); // start console spinner if (!debug) { spinner = new Thread(new Spinner()); spinner.start(); } // sample execution steps /***** Part 1 - Start the NV test with the "3G Busy" network scenario *****/ printPartDescription("\b------ Part 1 - Start the NV test with the \"3G Busy\" network scenario"); initTestManager(); startTest(); testRunning = true; printPartSeparator(); /***** Part 2 - Run three transactions - "Home Page", "Get Started" and "Overview" *****/ printPartDescription( "------ Part 2 - Run three transactions - \"Home Page\", \"Get Started\" and \"Overview\""); connectToTransactionManager(); startTransaction(1); transactionInProgress = true; buildSeleniumWebDriver(); seleniumNavigateToPage(); stopTransaction(1); transactionInProgress = false; startTransaction(2); transactionInProgress = true; seleniumGetStartedClick(); stopTransaction(2); transactionInProgress = false; startTransaction(3); transactionInProgress = true; seleniumOverviewClick(); stopTransaction(3); transactionInProgress = false; driverCloseAndQuit(); printPartSeparator(); /***** Part 3 - Stop the NV test, analyze it and print the results to the console *****/ printPartDescription( "------ Part 3 - Stop the NV test, analyze it and print the results to the console"); stopTestAndAnalyze(); testRunning = false; printPartSeparator(); doneCallback(); } catch (Exception e) { try { handleError(e.getMessage()); } catch (Exception e2) { System.out.println("Error occurred: " + e2.getMessage()); } } }
From source file:com.adito.server.Main.java
/** * Entry point/*from ww w.ja va 2 s .c o m*/ * * @param args * @throws Throwable */ public static void main(String[] args) throws Throwable { // This is a hack to allow the Install4J installer to get the java // runtime that will be used if (args.length > 0 && args[0].equals("--jvmdir")) { System.out.println(SystemProperties.get("java.home")); System.exit(0); } useWrapper = System.getProperty("wrapper.key") != null; final Main main = new Main(); ContextHolder.setContext(main); if (useWrapper) { WrapperManager.start(main, args); } else { Integer returnCode = main.start(args); if (returnCode != null) { if (main.gui) { if (main.startupException == null) { main.startupException = new Exception("An exit code of " + returnCode + " was returned."); } try { if (SystemProperties.get("os.name").toLowerCase().startsWith("windows")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) { } String mesg = main.startupException.getMessage() == null ? "No message supplied." : main.startupException.getMessage(); StringBuffer buf = new StringBuffer(); int l = 0; char ch = ' '; for (int i = 0; i < mesg.length(); i++) { ch = mesg.charAt(i); if (l > 50 && ch == ' ') { buf.append("\n"); l = 0; } else { if (ch == '\n') { l = 0; } else { l++; } buf.append(ch); } } mesg = buf.toString(); final String fMesg = mesg; SwingUtilities.invokeAndWait(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, fMesg, "Startup Error", JOptionPane.ERROR_MESSAGE); } }); } System.exit(returnCode.intValue()); } else { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (!main.shuttingDown) { main.stop(0); } } }); } } }
From source file:com.amazonaws.services.kinesis.aggregators.consumer.AggregatorConsumer.java
public static void main(String[] args) throws Exception { String streamName = System.getProperty(AggregatorsConstants.STREAM_NAME_PARAM); String appName = System.getProperty(AggregatorsConstants.APP_NAME_PARAM); String configFilePath = System.getProperty(AggregatorsConstants.CONFIG_PATH_PARAM); String regionName = System.getProperty(AggregatorsConstants.REGION_PARAM); String failuresToTolerate = System.getProperty(AggregatorsConstants.FAILURES_TOLERATED_PARAM); String maxRecords = System.getProperty(AggregatorsConstants.MAX_RECORDS_PARAM); String environmentName = System.getProperty(AggregatorsConstants.ENVIRONMENT_PARAM); String positionInStream = System.getProperty(AggregatorsConstants.STREAM_POSITION_PARAM); AggregatorConsumer consumer = new AggregatorConsumer(streamName, appName, configFilePath); // add optional configuration items if (regionName != null && regionName != "") { consumer.withRegionName(regionName); }/* w w w . j a v a 2s . c o m*/ if (failuresToTolerate != null && failuresToTolerate != "") { consumer.withToleratedWorkerFailures(Integer.parseInt(failuresToTolerate)); } if (maxRecords != null && maxRecords != "") { consumer.withMaxRecords(Integer.parseInt(maxRecords)); } if (environmentName != null && environmentName != "") { consumer.withEnvironment(environmentName); } if (positionInStream != null && positionInStream != "") { consumer.withInitialPositionInStream(positionInStream); } System.exit(consumer.run()); }
From source file:org.eclipse.swt.snippets.SnippetExplorer.java
/** * SnippetExplorer main method./* www. j a v a 2s . c o m*/ * * @param args does not parse any arguments */ public static void main(String[] args) throws Exception { final String os = System.getProperty("os.name"); multiDisplaySupport = (os != null && os.toLowerCase().contains("windows")); if (canRunCommand("java")) { javaCommand = "java"; } else { final String javaHome = System.getProperty("java.home"); if (javaHome != null) { final Path java = Paths.get(javaHome, "bin", "java"); java.normalize(); if (canRunCommand(java.toString())) { javaCommand = java.toString(); } } } snippets = loadSnippets(); snippets.sort((a, b) -> { int cmp = Integer.compare(a.snippetNum, b.snippetNum); if (cmp == 0) { cmp = a.snippetName.compareTo(b.snippetName); } return cmp; }); new SnippetExplorer().open(); }
From source file:org.pegadi.client.ApplicationLauncher.java
public static void main(String[] args) { com.sun.net.ssl.internal.ssl.Provider provider = new com.sun.net.ssl.internal.ssl.Provider(); java.security.Security.addProvider(provider); setAllPermissions();//from w ww .ja v a 2 s .c om /** * If we are on Apples operating system, we would like to use the screen * menu bar It is the first property we set in our main method. This is * to make sure that the property is set before awt is loaded. */ if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); } Logger log = LoggerFactory.getLogger(ApplicationLauncher.class); /** * Making sure default L&F is System */ if (!UIManager.getLookAndFeel().getName().equals(UIManager.getSystemLookAndFeelClassName())) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { log.warn("Unable to change L&F to System", e); } } long start = System.currentTimeMillis(); // Splash Splash splash = new Splash("/images/splash.png"); splash.setVisible(true); splash.setCursor(new Cursor(Cursor.WAIT_CURSOR)); if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/pegadi/client/client-context.xml"); closeContextOnShutdown(context); long timeToLogin = System.currentTimeMillis() - start; log.info("Connected OK after {} ms", timeToLogin); log.info("Java Version {}", System.getProperty("java.version")); splash.dispose(); }
From source file:io.sightly.tck.TCK.java
public static void main(String[] args) { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption(OptionBuilder.withLongOpt(CLI_EXTRACT).withDescription(CLI_EXTRACT_DESCRIPTION) .hasOptionalArg().withArgName("DIR").create()); options.addOption(OptionBuilder.withLongOpt(CLI_URL).withDescription(CLI_URL_DESCRIPTION).hasOptionalArg() .withArgName("URL").create()); options.addOption(OptionBuilder.withLongOpt(CLI_AUTH_USER).withDescription(CLI_AUTH_USER_DESCRIPTION) .hasOptionalArg().withArgName("USER").create()); options.addOption(OptionBuilder.withLongOpt(CLI_AUTH_PASS).withDescription(CLI_AUTH_PASS_DESCRIPTION) .hasOptionalArg().withArgName("PASS").create()); try {// ww w . j a v a 2 s . c o m CommandLine line = parser.parse(options, args); if (!line.iterator().hasNext()) { printUsage(options); die(); } else if (line.hasOption(CLI_EXTRACT)) { String extractDir = line.getOptionValue(CLI_EXTRACT); if (StringUtils.isEmpty(extractDir)) { // assume user wants to extract stuff in current directory extractDir = System.getProperty("user.dir"); } INSTANCE.extract(extractDir); LOG.info("Extracted testing resources in folder {}.", extractDir + File.separator + TESTFILES); } else { if (line.hasOption(CLI_URL)) { String url = line.getOptionValue(CLI_URL); if (StringUtils.isEmpty(url)) { LOG.error("Missing value for --" + CLI_URL + " command line option."); printUsage(options); die(); } System.setProperty(Constants.SYS_PROP_SERVER_URL, url); } if (line.hasOption(CLI_AUTH_USER) || line.hasOption(CLI_AUTH_PASS)) { String user = line.getOptionValue(CLI_AUTH_USER); if (StringUtils.isEmpty(user)) { LOG.error("Missing value for --" + CLI_AUTH_USER + " command line option"); printUsage(options); die(); } String pass = line.getOptionValue(CLI_AUTH_PASS); if (StringUtils.isEmpty(pass)) { LOG.error("Missing value for --" + CLI_AUTH_PASS + " command line option"); printUsage(options); die(); } System.setProperty(Constants.SYS_PROP_USER, user); System.setProperty(Constants.SYS_PROP_PASS, pass); } INSTANCE.run(); } } catch (ParseException e) { printUsage(options); die(); } catch (IOException e) { LOG.error("IO Error.", e); die(); } }
From source file:modnlp.capte.AlignmentInterfaceWS.java
public static void main(String args[]) { try {// w ww.j a v a 2s . co m //set splitting action equal to true //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); doSplit = true; //default AlreadyRun to false AlreadyRun = false; //lineConvert = true; lineConvert = true; // Read config file boolean isMac = false; boolean isWin = false; boolean isUnix = false; String tmp = ""; String winsep = "\\"; String unixsep = "/"; String ostype = System.getProperty("os.name").toLowerCase(); System.out.println("Operating system type =>" + ostype); if (ostype.indexOf("win") >= 0) { isWin = true; isUnix = false; isMac = false; } else if ((ostype.indexOf("nix") >= 0) || (ostype.indexOf("nux") >= 0)) { isUnix = true; isWin = false; isMac = false; } else if (ostype.indexOf("mac") >= 0) { isWin = false; isUnix = false; isMac = true; } else { throw new UnsupportedOperationException("your OS is not supported!"); } //creating and showing this application's GUI. SwingUtilities.invokeLater(new Runnable() { public void run() { //Turn off metal's use of bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); createAndShowGUI(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:FileLister.java
/** * A main() method so FileLister can be run standalone. Parse command line * arguments and create the FileLister object. If an extension is specified, * create a FilenameFilter for it. If no directory is specified, use the * current directory./* ww w .jav a2s . c o m*/ */ public static void main(String args[]) throws IOException { FileLister f; FilenameFilter filter = null; // The filter, if any String directory = null; // The specified dir, or the current dir // Loop through args array, parsing arguments for (int i = 0; i < args.length; i++) { if (args[i].equals("-e")) { if (++i >= args.length) usage(); final String suffix = args[i]; // final for anon. class below // This class is a simple FilenameFilter. It defines the // accept() method required to determine whether a specified // file should be listed. A file will be listed if its name // ends with the specified extension, or if it is a directory. filter = new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith(suffix)) return true; else return (new File(dir, name)).isDirectory(); } }; } else { if (directory != null) usage(); // If already specified, fail. else directory = args[i]; } } // if no directory specified, use the current directory if (directory == null) directory = System.getProperty("user.dir"); // Create the FileLister object, with directory and filter specified. f = new FileLister(directory, filter); // Arrange for the application to exit when the window is closed f.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } }); // Finally, pop the window up up. f.show(); }
From source file:com.cws.esolutions.core.main.NetworkUtility.java
public static final void main(final String[] args) { final String methodName = NetworkUtility.CNAME + "#main(final String[] args)"; if (DEBUG) {//from w w w . ja v a 2 s. c o m DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", (Object) args); } if (args.length == 0) { new HelpFormatter().printHelp(NetworkUtility.CNAME, options, true); return; } try { CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(options, args); if (DEBUG) { DEBUGGER.debug("CommandLineParser parser: {}", parser); DEBUGGER.debug("CommandLine commandLine: {}", commandLine); } String coreConfiguration = (StringUtils.isBlank(System.getProperty("coreConfigFile"))) ? NetworkUtility.CORE_SVC_CONFIG : System.getProperty("coreConfigFile"); String securityConfiguration = (StringUtils.isBlank(System.getProperty("secConfigFile"))) ? NetworkUtility.CORE_LOG_CONFIG : System.getProperty("secConfigFile"); String coreLogging = (StringUtils.isBlank(System.getProperty("coreLogConfig"))) ? NetworkUtility.SEC_SVC_CONFIG : System.getProperty("coreLogConfig"); String securityLogging = (StringUtils.isBlank(System.getProperty("secLogConfig"))) ? NetworkUtility.SEC_LOG_CONFIG : System.getProperty("secLogConfig"); if (DEBUG) { DEBUGGER.debug("String coreConfiguration: {}", coreConfiguration); DEBUGGER.debug("String securityConfiguration: {}", securityConfiguration); DEBUGGER.debug("String coreLogging: {}", coreLogging); DEBUGGER.debug("String securityLogging: {}", securityLogging); } SecurityServiceInitializer.initializeService(securityConfiguration, securityLogging, false); CoreServiceInitializer.initializeService(coreConfiguration, coreLogging, false, true); final CoreConfigurationData coreConfigData = NetworkUtility.appBean.getConfigData(); final SecurityConfigurationData secConfigData = NetworkUtility.secBean.getConfigData(); if (DEBUG) { DEBUGGER.debug("CoreConfigurationData coreConfigData: {}", coreConfigData); DEBUGGER.debug("SecurityConfigurationData secConfig: {}", secConfigData); } if (commandLine.hasOption("ssh")) { if (!(commandLine.hasOption("hostname")) || (!(StringUtils.isBlank(commandLine.getOptionValue("hostname"))))) { throw new CoreServiceException("No target host was provided. Unable to process request."); } else if (!(commandLine.hasOption("username")) && (StringUtils.isBlank(commandLine.getOptionValue("username")))) { throw new CoreServiceException("No username was provided. Using default."); } // NetworkUtils.executeSshConnection(commandLine.getOptionValue("hostname"), commandList); } else if (commandLine.hasOption("http")) { if (!(commandLine.hasOption("hostname")) || (!(StringUtils.isBlank(commandLine.getOptionValue("hostname"))))) { throw new CoreServiceException("No target host was provided. Unable to process request."); } else if (!(commandLine.hasOption("method")) && (StringUtils.isBlank(commandLine.getOptionValue("method")))) { throw new CoreServiceException("No HTTP method was provided. Unable to process request."); } NetworkUtils.executeHttpConnection(new URL(commandLine.getOptionValue("hostname")), commandLine.getOptionValue("method")); } else if (commandLine.hasOption("copyFiles")) { if (!(commandLine.hasOption("hostname")) || (StringUtils.isBlank(commandLine.getOptionValue("hostname")))) { throw new CoreServiceException("No target host was provided. Unable to process request."); } else if (!(commandLine.hasOption("sourceFile")) && (StringUtils.isBlank(commandLine.getOptionValue("sourceFile")))) { throw new CoreServiceException("No source file(s) were provided. Unable to process request."); } else if (!(commandLine.hasOption("targetFile")) && (StringUtils.isBlank(commandLine.getOptionValue("targetFile")))) { throw new CoreServiceException("No target file(s) were provided. Unable to process request."); } List<String> filesToTransfer = new ArrayList<String>( Arrays.asList(commandLine.getOptionValues("sourceFile"))); List<String> filesToCreate = new ArrayList<String>( Arrays.asList(commandLine.getOptionValues("targetFile"))); if (DEBUG) { DEBUGGER.debug("List<String> filesToTransfer: {}", filesToTransfer); DEBUGGER.debug("List<String> filesToCreate: {}", filesToCreate); } if (commandLine.hasOption("withSSH")) { for (String fileName : filesToTransfer) { if (DEBUG) { DEBUGGER.debug("String fileName: {}", fileName); } NetworkUtils.executeSftpTransfer(fileName, filesToCreate.get(filesToTransfer.indexOf(fileName)), commandLine.getOptionValue("hostname"), FileUtils.getFile(fileName).exists()); } } else if (commandLine.hasOption("withFTP")) { if ((commandLine.hasOption("withSSL")) && (Boolean.valueOf(commandLine.getOptionValue("withSSL")))) { // ftp/s } // NetworkUtils.executeFtpConnection(sourceFile, targetFile, targetHost, isUpload); } } } catch (ParseException px) { ERROR_RECORDER.error(px.getMessage(), px); System.err.println("An error occurred during processing: " + px.getMessage()); } catch (SecurityException sx) { ERROR_RECORDER.error(sx.getMessage(), sx); System.err.println("An error occurred during processing: " + sx.getMessage()); } catch (SecurityServiceException ssx) { ERROR_RECORDER.error(ssx.getMessage(), ssx); System.err.println("An error occurred during processing: " + ssx.getMessage()); } catch (CoreServiceException csx) { ERROR_RECORDER.error(csx.getMessage(), csx); System.err.println("An error occurred during processing: " + csx.getMessage()); } catch (MalformedURLException mux) { ERROR_RECORDER.error(mux.getMessage(), mux); System.err.println("An error occurred during processing: " + mux.getMessage()); } }
From source file:jsonbrowse.JsonBrowse.java
/** * @param args the command line arguments *///from w w w .j a v a2 s.co m public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(JsonBrowse.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> String fileName; // Get name of JSON file Path jsonFilePath; if (args.length < 1) { JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setDialogTitle("Select JSON file..."); fc.setFileFilter(new FileNameExtensionFilter("JSON files (*.json/*.txt)", "json", "txt")); if ((fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)) { jsonFilePath = fc.getSelectedFile().toPath().toAbsolutePath(); } else { return; } } else { Path path = Paths.get(args[0]); if (!path.isAbsolute()) jsonFilePath = Paths.get(System.getProperty("user.dir")).resolve(path); else jsonFilePath = path; } // Run app try { JsonBrowse app = new JsonBrowse(jsonFilePath); app.setVisible(true); } catch (FileNotFoundException ex) { System.out.println("Input file '" + jsonFilePath + "' not found."); System.exit(1); } catch (IOException ex) { System.out.println("Error reading from file '" + jsonFilePath + "'."); System.exit(1); } catch (InterruptedException ex) { Logger.getLogger(JsonBrowse.class.getName()).log(Level.SEVERE, null, ex); } }