Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key, String def) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(System.getProperty("password", "defaultPassword"));
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.println("  OS name: " + System.getProperty("os.name", "not specified"));
    System.out.println("  JVM Version: " + System.getProperty("java.version", "not specified"));
    System.out.println("  user.home: " + System.getProperty("user.home", "not specified"));
    System.out.println("  java.home: " + System.getProperty("java.home", "not specified"));
}

From source file:Main.java

public static void main(String[] args) {

    // gets the system property 
    System.out.println(System.getProperty("string", "java2s.com"));
}

From source file:Main.java

public static void main(String[] args) {
    String path = System.getProperty("user.dir", ".");

    File dir = new File(path);

    JFileChooser jfc = new JFileChooser(dir);
    int result = jfc.showOpenDialog(null);

    switch (result) {
    case JFileChooser.CANCEL_OPTION:
        System.out.println("User cancelled OPEN dialog.");
        break;/*from  ww w. j a v  a2 s. c om*/
    case JFileChooser.APPROVE_OPTION:
        System.out.println("User chose file: " + jfc.getSelectedFile());
        break;
    case JFileChooser.ERROR_OPTION:
        System.out.println("User encountered an error");
        break;
    default:
        System.out.println("Confused");
        break;
    }

    System.exit(0);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {

    String serverName = System.getProperty("WHOIS_SERVER", DEFAULT_HOST);

    InetAddress server = null;/*from   w  ww. ja  v a  2s .c o m*/
    server = InetAddress.getByName(serverName);
    Socket theSocket = new Socket(server, DEFAULT_PORT);
    Writer out = new OutputStreamWriter(theSocket.getOutputStream(), "8859_1");
    out.write("\r\n");
    out.flush();
    InputStream raw = theSocket.getInputStream();
    InputStream in = new BufferedInputStream(theSocket.getInputStream());
    int c;
    while ((c = in.read()) != -1)
        System.out.write(c);
}

From source file:com.ponysdk.impl.spring.MainSpring.java

public static void main(final String[] args) {
    final String serverConfigLocation = System.getProperty(SpringApplicationManager.SERVER_CONFIG_LOCATION,
            "classpath:etc/server_application.xml");

    new ClassPathXmlApplicationContext(serverConfigLocation);
}

From source file:org.openmrs.ModuleStory.java

public static void main(String args[]) throws IOException, InterruptedException {
    if (!skipDatabaseSetupPage()) {
        String databaseUserName = System.getProperty("database_user_name", "root");
        String databaseRootPassword = System.getProperty("database_root_password", "password");
        Runtime runtime = Runtime.getRuntime();
        runtime.exec("curl http://localhost:8080/openmrs/auto_run_openmrs?local=en&remember=true"
                + "&database_user_name=" + databaseUserName + "&database_root_password="
                + databaseRootPassword);
        log.debug("Waiting 10 minutes for OpenMRS installation to complete!!");
        Thread.sleep(1000 * 60 * 10); //Waiting 10 minutes for installation to complete
    }//ww w . java2  s.  co  m
}

From source file:com.asual.summer.onejar.OneJarServer.java

public static void main(String[] args) throws Exception {
    Server server = new Server(Integer.valueOf(System.getProperty("server.port", "8080")));
    server.setHandler(new WebAppContext(getCurrentWarFile(), System.getProperty("server.contextPath", "/")));
    try {//from ww w.j  a  v a 2s.  co m
        server.start();
    } catch (Exception e) {
        server.stop();
        e.printStackTrace();
        System.exit(-1);
    }
}

From source file:com.alibaba.otter.manager.deployer.OtterManagerLauncher.java

public static void main(String[] args) throws Throwable {
    try {//  w  w w .  ja v a2s .  co  m
        String conf = System.getProperty("otter.conf", "classpath:otter.properties");
        Properties properties = new Properties();
        if (conf.startsWith(CLASSPATH_URL_PREFIX)) {
            conf = StringUtils.substringAfter(conf, CLASSPATH_URL_PREFIX);
            properties.load(OtterManagerLauncher.class.getClassLoader().getResourceAsStream(conf));
        } else {
            properties.load(new FileInputStream(conf));
        }

        // ??system?
        mergeProps(properties);

        logger.info("## start the manager server.");
        final JettyEmbedServer server = new JettyEmbedServer(
                properties.getProperty("otter.jetty", "jetty.xml"));
        server.start();
        logger.info("## the manager server is running now ......");
        Runtime.getRuntime().addShutdownHook(new Thread() {

            public void run() {
                try {
                    logger.info("## stop the manager server");
                    server.join();
                } catch (Throwable e) {
                    logger.warn("##something goes wrong when stopping manager Server:\n{}",
                            ExceptionUtils.getFullStackTrace(e));
                } finally {
                    logger.info("## manager server is down.");
                }
            }

        });
    } catch (Throwable e) {
        logger.error("## Something goes wrong when starting up the manager Server:\n{}",
                ExceptionUtils.getFullStackTrace(e));
        System.exit(0);
    }
}

From source file:alfio.config.SpringBootLauncher.java

/**
 * Entry point for spring boot/*from w w w .ja va 2  s . c  o m*/
 * @param args original arguments
 */
public static void main(String[] args) {
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    String profiles = System.getProperty("spring.profiles.active", "");

    SpringApplication application = new SpringApplication(SpringBootInitializer.class,
            RepositoryConfiguration.class, DataSourceConfiguration.class, WebSecurityConfig.class,
            MvcConfiguration.class);
    List<String> additionalProfiles = new ArrayList<>();
    additionalProfiles.add(Initializer.PROFILE_SPRING_BOOT);
    if ("true".equals(System.getenv("ALFIO_LOG_STDOUT_ONLY"))) {
        // -> will load application-stdout.properties on top to override the logger configuration
        additionalProfiles.add("stdout");
    }
    if ("true".equals(System.getenv("ALFIO_DEMO_ENABLED"))) {
        additionalProfiles.add(Initializer.PROFILE_DEMO);
    }
    if ("true".equals(System.getenv("ALFIO_JDBC_SESSION_ENABLED"))) {
        additionalProfiles.add(Initializer.PROFILE_JDBC_SESSION);
    }
    application.setAdditionalProfiles(additionalProfiles.toArray(new String[additionalProfiles.size()]));
    ConfigurableApplicationContext applicationContext = application.run(args);
    ConfigurableEnvironment environment = applicationContext.getEnvironment();
    log.info("profiles: requested {}, active {}", profiles,
            String.join(", ", (CharSequence[]) environment.getActiveProfiles()));
    if ("true".equals(System.getProperty("startDBManager"))) {
        launchHsqlGUI();
    }
}