List of usage examples for java.lang System getProperty
public static String getProperty(String key, String def)
From source file:org.echocat.nodoodle.server.Main.java
public static void main(String[] args) { final File log4jConfig = new File(System.getProperty("log4j.configuration", "../config/log4j.xml")); if (log4jConfig.isFile()) { try {//from w w w . j a v a 2 s . co m final FileReader reader = new FileReader(log4jConfig); try { final DOMConfigurator domConfigurator = new DOMConfigurator(); domConfigurator.doConfigure(reader, getLoggerRepository()); } finally { IOUtils.closeQuietly(reader); } } catch (Exception e) { throw new RuntimeException("Could not configure log4j with " + log4jConfig + ".", e); } } final String applicationName = getApplicationName(); //System.setSecurityManager(new ServerSecurityManager()); LOG.info("Starting " + applicationName + "..."); final File config = new File( System.getProperty(Main.class.getPackage().getName() + ".config", "../config/nodoodleServer.xml")); final AbstractApplicationContext applicationContext = new FileSystemXmlApplicationContext(config.getPath()); LOG.info("Starting " + applicationName + "... DONE!"); Runtime.getRuntime().addShutdownHook(new Thread("destroyer") { @Override public void run() { LOG.info("Stopping " + applicationName + "..."); applicationContext.stop(); LOG.info("Stopping " + applicationName + "... DONE!"); } }); }
From source file:org.zaizi.sensefy.api.SensefyResourceApplication.java
public static void main(String[] args) { SpringApplication.run(SensefyResourceApplication.class, args); int port = Integer.parseInt(System.getProperty("jetty.port", "8080")); int requestHeaderSize = Integer.parseInt(System.getProperty("jetty.header.size", "65536")); Server server = new Server(port); server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", -1); ProtectionDomain domain = SensefyResourceApplication.class.getProtectionDomain(); URL location = domain.getCodeSource().getLocation(); // Set request header size // server.getConnectors()[0].setRequestHeaderSize(requestHeaderSize); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/api"); webapp.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml"); webapp.setServer(server);/*from w ww. ja v a 2 s . co m*/ webapp.setWar(location.toExternalForm()); // (Optional) Set the directory the war will extract to. // If not set, java.io.tmpdir will be used, which can cause problems // if the temp directory gets cleaned periodically. // Your build scripts should remove this directory between deployments // webapp.setTempDirectory(new File("/path/to/webapp-directory")); server.setHandler(webapp); try { server.start(); server.join(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:javasnack.cli.CliDbUnitCsvExportDemo.java
public static void main(String[] args) throws Exception { String driver = System.getProperty("CliDbUnitCsvExportDemo.driver", "org.h2.Driver"); Class.forName(driver);/*from www . jav a2 s .com*/ String url = System.getProperty("CliDbUnitCsvExportDemo.url", "jdbc:h2:mem:CliDbUnitCsvExportDemo"); String dbUser = System.getProperty("CliDbUnitCsvExportDemo.dbUser", "sa"); String dbPassword = System.getProperty("CliDbUnitCsvExportDemo.dbPassword", ""); Connection conn = DriverManager.getConnection(url, dbUser, dbPassword); CliDbUnitCsvExportDemo demo = new CliDbUnitCsvExportDemo(); demo.setup(conn); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); Calendar c = Calendar.getInstance(); File outDir = new File(sdf1.format(c.getTime())); outDir.mkdir(); IDatabaseConnection dbunit_conn = new DatabaseConnection(conn); IDataSet dataSet = dbunit_conn.createDataSet(); CsvBase64BinarySafeDataSetWriter.write(dataSet, outDir); conn.close(); }
From source file:com.daon.identityx.utils.GenerateAndroidFacet.java
public static void main(String[] args) { String androidKeystoreLocation = System.getProperty("ANDROID_KEYSTORE_LOCATION", DEFAULT_ANDROID_KEYSTORE_LOCATION); String androidKeystorePassword = System.getProperty("ANDROID_KEYSTORE_PASSWORD", DEFAULT_ANDROID_KEYSTORE_PASSWORD); String androidKeystoreCert = System.getProperty("ANDROID_KEYSTORE_CERT_NAME", DEFAULT_ANDROID_KEYSTORE_CERT_NAME); String hashingAlgorithm = System.getProperty("HASHING_ALGORITHM", DEFAULT_HASHING_ALGORITHM); try {// w w w . j a v a 2s. c o m KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); File filePath = new File(androidKeystoreLocation); if (!filePath.exists()) { System.err.println( "The filepath to the debug keystore could not be located at: " + androidKeystoreCert); System.exit(1); } else { System.out.println("Found the Android Studio keystore at: " + androidKeystoreLocation); } keyStore.load(new FileInputStream(filePath), androidKeystorePassword.toCharArray()); System.out.println("Keystore loaded - password and location were OK"); Certificate cert = keyStore.getCertificate(androidKeystoreCert); if (cert == null) { System.err.println( "Could not location the certification in the store with the name: " + androidKeystoreCert); System.exit(1); } else { System.out.println("Certificate found in the store with name: " + androidKeystoreCert); } byte[] certBytes = cert.getEncoded(); MessageDigest digest = MessageDigest.getInstance(hashingAlgorithm); System.out.println("Hashing algorithm: " + hashingAlgorithm + " found."); byte[] hashedCert = digest.digest(certBytes); String base64HashedCert = Base64.getEncoder().encodeToString(hashedCert); System.out.println("Base64 encoded SHA-1 hash of the certificate: " + base64HashedCert); String base64HashedCertRemoveTrailing = StringUtils.deleteAny(base64HashedCert, "="); System.out.println( "Add the following facet to the Facets file in order for the debug app to be trusted by the FIDO client"); System.out.println("\"android:apk-key-hash:" + base64HashedCertRemoveTrailing + "\""); } catch (Throwable ex) { ex.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] arguments) { String home, system;//ww w . java 2s . c om home = System.getProperty("user.home", "."); system = home + File.separatorChar + ".database"; System.setProperty("derby.system.home", system); createDatabase(); readDatabase(); }
From source file:com.sshtools.daemon.SshDaemon.java
/** * * * @param args/*from w ww . ja v a2 s. c om*/ */ public static void main(String[] args) { try { XmlServerConfigurationContext context = new XmlServerConfigurationContext(); context.setServerConfigurationResource( ConfigurationLoader.checkAndGetProperty("sshtools.server", "server.xml")); context.setPlatformConfigurationResource(System.getProperty("sshtools.platform", "platform.xml")); ConfigurationLoader.initialize(false, context); XmlConfigurationContext context2 = new XmlConfigurationContext(); context2.setFailOnError(false); context2.setAutomationConfigurationResource( ConfigurationLoader.checkAndGetProperty("sshtools.automate", "automation.xml")); ConfigurationLoader.initialize(false, context2); if (args.length > 0) { if (args[0].equals("-start")) { start(); } else if (args[0].equals("-stop")) { if (args.length > 1) { stop(args[1]); } else { stop("The framework daemon is shutting down"); } } else { System.out.println("Usage: SshDaemon [-start|-stop]"); } } else { System.out.println("Usage: SshDaemon [-start|-stop]"); } } catch (Exception e) { log.error("The server failed to process the " + ((args.length > 0) ? args[0] : "") + " command", e); } }
From source file:GetProps.java
public static void main(String[] args) { /* Test reading properties w & w/out security manager */ String s;//from w ww . ja v a 2s. c om try { System.out.println("About to get os.name property value"); s = System.getProperty("os.name", "not specified"); System.out.println(" The name of your operating system is: " + s); System.out.println("About to get java.version property value"); s = System.getProperty("java.version", "not specified"); System.out.println(" The version of the JVM you are running is: " + s); System.out.println("About to get user.home property value"); s = System.getProperty("user.home", "not specified"); System.out.println(" Your user home directory is: " + s); System.out.println("About to get java.home property value"); s = System.getProperty("java.home", "not specified"); System.out.println(" Your JRE installation directory is: " + s); } catch (Exception e) { System.err.println("Caught exception " + e.toString()); } }
From source file:cz.muni.fi.pa165.rentalofconstructionmachinery.restclient.App.java
public static int main(String[] args) { infoLogger.info("\n\nREST Sample Client\n\n"); HttpHeaders httpHeaders = new HttpHeaders(); String auth = REST_USERNAME + ":" + REST_PASSWORD; byte[] encodedAuthorisation = Base64.encode(auth.getBytes()); httpHeaders.add("Authorization", "Basic " + new String(encodedAuthorisation)); CustomerRestController.setHttpHeaders(httpHeaders); MachineRestController.setHttpHeaders(httpHeaders); try {//from w ww.ja v a2s. co m switch (System.getProperty(ACTION, "")) { case "list": listEntities(); break; case "details": getDetails(); break; case "create": createEntity(); break; case "edit": editEntity(); break; case "delete": deleteEntity(); break; default: infoLogger.info("Please, see the usage guide for this client in the README file."); } } catch (Exception e) { errorLogger.error("Houston, we have a problem.", e); infoLogger.info("\n\n"); infoLogger.info("Ooops."); return 1; } infoLogger.info("\n\n"); infoLogger.info("The operation was successful."); return 0; }
From source file:eu.interedition.collatex.http.Server.java
public static void main(String... args) { try {//from w w w . ja v a 2s .c o m final CommandLine commandLine = new GnuParser().parse(OPTIONS, args); if (commandLine.hasOption("h")) { new HelpFormatter().printHelp("collatex-server [<options> ...]\n", OPTIONS); return; } final Collator collator = new Collator(Integer.parseInt(commandLine.getOptionValue("mpc", "2")), Integer.parseInt(commandLine.getOptionValue("mcs", "0")), commandLine.getOptionValue("dot", null)); final String staticPath = System.getProperty("collatex.static.path", ""); final HttpHandler httpHandler = staticPath.isEmpty() ? new CLStaticHttpHandler(Server.class.getClassLoader(), "/static/") { @Override protected void onMissingResource(Request request, Response response) throws Exception { collator.service(request, response); } } : new StaticHttpHandler(staticPath.replaceAll("/+$", "") + "/") { @Override protected void onMissingResource(Request request, Response response) throws Exception { collator.service(request, response); } }; final NetworkListener httpListener = new NetworkListener("http", "0.0.0.0", Integer.parseInt(commandLine.getOptionValue("p", "7369"))); final CompressionConfig compressionConfig = httpListener.getCompressionConfig(); compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON); compressionConfig.setCompressionMinSize(860); // http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits compressionConfig.setCompressableMimeTypes("application/javascript", "application/json", "application/xml", "text/css", "text/html", "text/javascript", "text/plain", "text/xml"); final HttpServer httpServer = new HttpServer(); httpServer.addListener(httpListener); httpServer.getServerConfiguration().addHttpHandler(httpHandler, commandLine.getOptionValue("cp", "").replaceAll("/+$", "") + "/*"); Runtime.getRuntime().addShutdownHook(new Thread(() -> { if (LOG.isLoggable(Level.INFO)) { LOG.info("Stopping HTTP server"); } httpServer.shutdown(); })); httpServer.start(); Thread.sleep(Long.MAX_VALUE); } catch (Throwable t) { LOG.log(Level.SEVERE, "Error while parsing command line", t); System.exit(1); } }
From source file:com.github.xbn.examples.regexutil.non_xbn.BetweenLineMarkersButSkipFirstXmpl.java
public static final void main(String[] as_1RqdTxtFilePath) { Iterator<String> lineItr = null; try {//from w w w .j ava 2 s .co m lineItr = FileUtils.lineIterator(new File(as_1RqdTxtFilePath[0])); //Throws npx if null } catch (IOException iox) { throw new RuntimeException("Attempting to open \"" + as_1RqdTxtFilePath[0] + "\"", iox); } catch (RuntimeException rx) { throw new RuntimeException("One required parameter: The path to the text file.", rx); } String LINE_SEP = System.getProperty("line.separator", "\n"); ArrayList<String> alsItems = new ArrayList<String>(); boolean bStartMark = false; boolean bLine1Skipped = false; StringBuilder sdCurrentItem = new StringBuilder(); while (lineItr.hasNext()) { String sLine = lineItr.next().trim(); if (!bStartMark) { if (sLine.startsWith(".START_SEQUENCE")) { bStartMark = true; continue; } throw new IllegalStateException("Start mark not found."); } if (!bLine1Skipped) { bLine1Skipped = true; continue; } else if (!sLine.equals(".END_SEQUENCE")) { sdCurrentItem.append(sLine).append(LINE_SEP); } else { alsItems.add(sdCurrentItem.toString()); sdCurrentItem.setLength(0); bStartMark = false; bLine1Skipped = false; continue; } } for (String s : alsItems) { System.out.println("----------"); System.out.print(s); } }