1. We can use System.getProperty(systemPropertyString) to retrieve the values, such as java.version, java.home, os.name, user.name, user.home, user.dir, java.io.tmpdir etc;
2. Use System.getenv to enumerate all the system environment:
==============================================================
import java.util.*;
public class ListEnv {
- public static void listAllEnv(){
- Map variables = System.getenv();
Set variableNames = variables.keySet();
Iterator nameIterator = variableNames.iterator();
for(int index=0; index < variableNames.size(); index++){
- String name = (String) nameIterator.next();
String value = (String) variables.get(name);
System.out.println(name + "=" + value);
- String name = (String) nameIterator.next();
public static void main(String[] args) {
- listAllEnv();
- Map variables = System.getenv();
==============================================================
No comments:
Post a Comment