Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

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

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Custom Tip Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Properties props = System.getProperties();
    MainClass list = new MainClass(props);
    JScrollPane scrollPane = new JScrollPane(list);
    frame.add(scrollPane);// w w  w. j a v  a  2 s  .com
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:ToolTipTreeCellRenderer.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tree Tips");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Properties props = System.getProperties();
    JTree tree = new JTree(props);

    ToolTipManager.sharedInstance().registerComponent(tree);
    TreeCellRenderer renderer = new ToolTipTreeCellRenderer(props);

    tree.setCellRenderer(renderer);/*from  w  ww  . j  a v  a2s  .c o m*/
    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:dhtaccess.tools.Remove.java

public static void main(String[] args) {
    int ttl = 3600;

    // parse properties
    Properties prop = System.getProperties();
    String gateway = prop.getProperty("dhtaccess.gateway");
    if (gateway == null || gateway.length() <= 0) {
        gateway = DEFAULT_GATEWAY;//from www .  j a  v a2 s  .  c  o  m
    }

    // parse options
    Options options = new Options();
    options.addOption("h", "help", false, "print help");
    options.addOption("g", "gateway", true, "gateway URI, list at http://opendht.org/servers.txt");
    options.addOption("t", "ttl", true, "how long (in seconds) to store the value");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println("There is an invalid option.");
        e.printStackTrace();
        System.exit(1);
    }

    String optVal;
    if (cmd.hasOption('h')) {
        usage(COMMAND);
        System.exit(1);
    }
    optVal = cmd.getOptionValue('g');
    if (optVal != null) {
        gateway = optVal;
    }
    optVal = cmd.getOptionValue('t');
    if (optVal != null) {
        ttl = Integer.parseInt(optVal);
    }

    args = cmd.getArgs();

    // parse arguments
    if (args.length < 3) {
        usage(COMMAND);
        System.exit(1);
    }

    byte[] key = null, value = null, secret = null;
    try {
        key = args[0].getBytes(ENCODE);
        value = args[1].getBytes(ENCODE);
        secret = args[2].getBytes(ENCODE);
    } catch (UnsupportedEncodingException e1) {
        // NOTREACHED
    }

    // prepare for RPC
    DHTAccessor accessor = null;
    try {
        accessor = new DHTAccessor(gateway);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        System.exit(1);
    }

    // RPC
    int res = accessor.remove(key, value, ttl, secret);

    String resultString;
    switch (res) {
    case 0:
        resultString = "Success";
        break;
    case 1:
        resultString = "Capacity";
        break;
    case 2:
        resultString = "Again";
        break;
    default:
        resultString = "???";
    }
    System.out.println(resultString);
}

From source file:dhtaccess.tools.Put.java

public static void main(String[] args) {
    byte[] secret = null;
    int ttl = 3600;

    // parse properties
    Properties prop = System.getProperties();
    String gateway = prop.getProperty("dhtaccess.gateway");
    if (gateway == null || gateway.length() <= 0) {
        gateway = DEFAULT_GATEWAY;/*from www .j  a va 2s. com*/
    }

    // parse options
    Options options = new Options();
    options.addOption("h", "help", false, "print help");
    options.addOption("g", "gateway", true, "gateway URI, list at http://opendht.org/servers.txt");
    options.addOption("s", "secret", true, "can be used to remove the value later");
    options.addOption("t", "ttl", true, "how long (in seconds) to store the value");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println("There is an invalid option.");
        e.printStackTrace();
        System.exit(1);
    }

    String optVal;
    if (cmd.hasOption('h')) {
        usage(COMMAND);
        System.exit(1);
    }
    optVal = cmd.getOptionValue('g');
    if (optVal != null) {
        gateway = optVal;
    }
    optVal = cmd.getOptionValue('s');
    if (optVal != null) {
        try {
            secret = optVal.getBytes(ENCODE);
        } catch (UnsupportedEncodingException e) {
            // NOTREACHED
        }
    }
    optVal = cmd.getOptionValue('t');
    if (optVal != null) {
        ttl = Integer.parseInt(optVal);
    }

    args = cmd.getArgs();

    // parse arguments
    if (args.length < 2) {
        usage(COMMAND);
        System.exit(1);
    }

    for (int index = 0; index + 1 < args.length; index += 2) {
        byte[] key = null, value = null;
        try {
            key = args[index].getBytes(ENCODE);
            value = args[index + 1].getBytes(ENCODE);
        } catch (UnsupportedEncodingException e1) {
            // NOTREACHED
        }

        // prepare for RPC
        DHTAccessor accessor = null;
        try {
            accessor = new DHTAccessor(gateway);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            System.exit(1);
        }

        // RPC
        int res = accessor.put(key, value, ttl, secret);

        String resultString;
        switch (res) {
        case 0:
            resultString = "Success";
            break;
        case 1:
            resultString = "Capacity";
            break;
        case 2:
            resultString = "Again";
            break;
        default:
            resultString = "???";
        }
        System.out.println(resultString + ": " + args[index] + ", " + args[index + 1]);
    }
}

From source file:dhtaccess.tools.Get.java

public static void main(String[] args) {
    boolean details = false;

    // parse properties
    Properties prop = System.getProperties();
    String gateway = prop.getProperty("dhtaccess.gateway");
    if (gateway == null || gateway.length() <= 0) {
        gateway = DEFAULT_GATEWAY;// w  ww . j a  v  a  2s . c  o  m
    }

    // parse options
    Options options = new Options();
    options.addOption("h", "help", false, "print help");
    options.addOption("g", "gateway", true, "gateway URI, list at http://opendht.org/servers.txt");
    options.addOption("d", "details", false, "print secret hash and TTL");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println("There is an invalid option.");
        e.printStackTrace();
        System.exit(1);
    }

    String optVal;
    if (cmd.hasOption('h')) {
        usage(COMMAND);
        System.exit(1);
    }
    optVal = cmd.getOptionValue('g');
    if (optVal != null) {
        gateway = optVal;
    }
    if (cmd.hasOption('d')) {
        details = true;
    }

    args = cmd.getArgs();

    // parse arguments
    if (args.length < 1) {
        usage(COMMAND);
        System.exit(1);
    }

    // prepare for RPC
    DHTAccessor accessor = null;
    try {
        accessor = new DHTAccessor(gateway);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        System.exit(1);
    }

    for (int index = 0; index < args.length; index++) {
        byte[] key = null;
        try {
            key = args[index].getBytes(ENCODE);
        } catch (UnsupportedEncodingException e1) {
            // NOTREACHED
        }

        // RPC
        if (args.length > 1) {
            System.out.println(args[index] + ":");
        }

        if (details) {
            Set<DetailedGetResult> results = accessor.getDetails(key);

            for (DetailedGetResult r : results) {
                String valString = null;
                try {
                    valString = new String((byte[]) r.getValue(), ENCODE);
                } catch (UnsupportedEncodingException e) {
                    // NOTREACHED
                }

                BigInteger hashedSecure = new BigInteger(1, (byte[]) r.getHashedSecret());

                System.out.println(valString + " " + r.getTTL() + " " + r.getHashType() + " 0x"
                        + ("0000000" + hashedSecure.toString(16)).substring(0, 8));
            }
        } else {
            Set<byte[]> results = accessor.get(key);

            for (byte[] valBytes : results) {
                try {
                    System.out.println(new String((byte[]) valBytes, ENCODE));
                } catch (UnsupportedEncodingException e) {
                    // NOTREACHED
                }
            }
        }
    } // for (int index = 0...
}

From source file:DisplaySystemProps.java

public static void main(String[] args) {
    System.getProperties().list(System.out);
}

From source file:com.sec.ose.osi.UIMain.java

public static void main(String[] args) {
    log.debug("Start GUI Application : " + Version.getApplicationVersionInfo());

    // check java version
    final double MINIMUM_VERSION = 1.6; // SwingWorker is since 1.6

    log.debug("Checking Java version.");

    double cur_version = getJavaVersion();
    Properties prop = System.getProperties();
    String msg = "You need the latest JVM version to execute " + Version.getApplicationVersionInfo()
            + "\nYou can download JVM(JRE or JDK) at http://java.sun.com" + "\n -Minimun JVM to execute: Java "
            + MINIMUM_VERSION + "\n -Current version: Java " + prop.getProperty("java.version")
            + "\n -Local java home directory: " + prop.getProperty("java.home");

    if (cur_version < MINIMUM_VERSION) {
        JOptionPane.showMessageDialog(null, msg, "Incompatible JVM", JOptionPane.ERROR_MESSAGE);

        log.debug(msg);//from   w ww .  j  a v  a2  s.c  o m
        System.exit(0);
    }

    // App Initialize
    BackgroundJobManager.getInstance().startBeforeLoginTaskThread();

    log.debug("Loading \"Login Frame\"");

    // login
    JFrame frmLogin = new JFrmLogin();
    UISharedData.getInstance().setCurrentFrame(frmLogin);
    frmLogin.setVisible(true);

    // check for only one OSI
    if (isRunning()) {
        JOptionPane.showMessageDialog(null, "OSI already has started. The program will be closed.", "Error",
                JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }

    // tray icon create
    new JTrayIconApp("OSIT", frmLogin);
}

From source file:com.pinterest.terrapin.thrift.TerrapinThriftMain.java

public static void main(String[] args) throws Exception {
    final PropertiesConfiguration config = TerrapinUtil.readPropertiesExitOnFailure(
            System.getProperties().getProperty("terrapin.config", "thrift.properties"));

    OstrichStatsReceiver statsReceiver = new OstrichStatsReceiver(Stats.get(""));
    int listenPort = config.getInt("thrift_port", 9090);
    TerrapinServiceImpl serviceImpl = new TerrapinServiceImpl(config, (List) config.getList("cluster_list"));
    Service<byte[], byte[]> service = new TerrapinService.Service(serviceImpl, new TBinaryProtocol.Factory());
    Server server = ServerBuilder.safeBuild(service,
            ServerBuilder.get().name("TERRAPIN_THRIFT").codec(ThriftServerFramedCodec.get())
                    .hostConnectionMaxIdleTime(Duration.apply(1, TimeUnit.MINUTES)).maxConcurrentRequests(3000)
                    .reportTo(statsReceiver).bindTo(new InetSocketAddress(listenPort)));
    new OstrichAdminService(config.getInt(Constants.OSTRICH_METRICS_PORT, 9999)).start();
    LOG.info("\n#######################################" + "\n#      Ready To Serve Requests.       #"
            + "\n#######################################");
}

From source file:com.pinterest.terrapin.hadoop.S3Uploader.java

public static void main(String[] args) {
    TerrapinUploaderOptions uploaderOptions = TerrapinUploaderOptions.initFromSystemProperties();
    uploaderOptions.validate();/*ww w. j a  va2 s  .  c om*/

    String s3Bucket = System.getProperties().getProperty("terrapin.s3bucket");
    String s3Prefix = System.getProperties().getProperty("terrapin.s3key_prefix");
    Preconditions.checkNotNull(s3Bucket);
    Preconditions.checkNotNull(s3Prefix);

    try {
        new S3Uploader(uploaderOptions, s3Bucket, s3Prefix).upload(uploaderOptions.terrapinCluster,
                uploaderOptions.terrapinFileSet, uploaderOptions.loadOptions);
    } catch (Exception e) {
        LOG.error("Upload FAILED.", e);
        System.exit(1);
    }
    // We need to force an exit since some of the netty threads instantiated as part
    // of the process are not daemon threads.
    System.exit(0);
}

From source file:de.ingrid.interfaces.csw.admin.IndexDriver.java

/**
 * @param args//from   w  w w.  j  a  v a 2  s. c  om
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    if (!System.getProperties().containsKey("jetty.webapp"))
        log.warn("Property 'jetty.webapp' not defined! Using default webapp directory, which is '"
                + DEFAULT_WEBAPP_DIR + "'.");
    if (!System.getProperties().containsKey("jetty.port"))
        log.warn("Property 'jetty.port' not defined! Using default port, which is '" + DEFAULT_JETTY_PORT
                + "'.");

    WebAppContext webAppContext = new WebAppContext(System.getProperty("jetty.webapp", DEFAULT_WEBAPP_DIR),
            "/");

    Server server = new Server(Integer.getInteger("jetty.port", DEFAULT_JETTY_PORT));
    // fix slow startup time on virtual machine env.
    HashSessionIdManager hsim = new HashSessionIdManager();
    hsim.setRandom(new Random());
    server.setSessionIdManager(hsim);
    server.setHandler(webAppContext);
    server.start();
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(
            webAppContext.getServletContext(),
            "org.springframework.web.servlet.FrameworkServlet.CONTEXT.springapp");
    IndexRunnable r = (IndexRunnable) wac.getBean("indexRunnable");
    r.run();
    System.out.println("Try to stopping the iPlug...");
    server.stop();
    System.out.println("iPlug is stopped.");
}