Here is an example for getting the environmental variables on a Windows machine.
package environmentalvariables;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
*
* @author nurhak.kaya
*/
public class EnvironmentalVariables {
public static void main(String[] args) {
Map map = System.getenv();
Set keys = map.keySet();
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next().toString();
String value = map.get(key).toString();
System.out.println(key + " --> " + value);
}
}
}
package environmentalvariables;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
*
* @author nurhak.kaya
*/
public class EnvironmentalVariables {
public static void main(String[] args) {
Map map = System.getenv();
Set keys = map.keySet();
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next().toString();
String value = map.get(key).toString();
System.out.println(key + " --> " + value);
}
}
}
Comments
Post a Comment