Home > Java > javaTutorial > Java obtains system environment variables and system properties

Java obtains system environment variables and system properties

高洛峰
Release: 2016-12-17 13:19:03
Original
1249 people have browsed it

java obtains system environment variables and system properties

代码

package jdk.system;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @author <a href="mailto:zhangting@taobao.com">张挺</a>
 * @since 2010-3-26 10:11:16
 */
public class SystemEnvDemo {
    public static void main(String[] args) {
        System.out.println("current system environment variable:");
        Map<String,String> map = System.getenv();
        Set<Map.Entry<String,String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }

        System.out.println("---------------");
        System.out.println("current system properties:");
        Properties properties = System.getProperties();
        Set<Map.Entry<Object, Object>> set = properties.entrySet();
        for (Map.Entry<Object, Object> objectObjectEntry : set) {
            System.out.println(objectObjectEntry.getKey() + ":" + objectObjectEntry.getValue());
        }

    }
}
Copy after login


For more articles related to java obtaining system environment variables and system properties, please pay attention to the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template