Environment Variables In Java

Environment Variables In Java

 

Environment Variables  are variables that are added in any Operating system that can be accessed from anywhere in OS without using the complete(Real) location.
 
In a java Application System.getenv(); is used to find out the system environment variables

Example:-

import java.util.Map;

public class EnvMap {
public static void main (String[] args) {
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format(“%s=%s%n”,
envName,
env.get(envName));
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *