As the title says, the code is relatively simple and is written for novices. Veterans can read other articles!
public static void main(String[] args) { //属性 System.out.println("系统属性......"); Properties props = System.getProperties(); Set<Object> sets = props.keySet(); for (Object objKey : sets) { System.out.println("属性名:【"+objKey+"】\n属性值:"+props.getProperty((String) objKey)+"\n"); } //环境变量 System.out.println("\n\n环境变量......"); Map<String, String> env = System.getenv(); Set<String> keySet = env.keySet(); for (String key : keySet) { System.out.println("【"+key+"】\t:\t【"+env.get(key)+"】\n"); } }
For more articles related to Java basics of obtaining system properties and environment variables, please pay attention to the PHP Chinese website!