Program to demonstrate how to query Environment Variables through Java.
Click here to download complete source code
Click here to download complete source code
Output of the program :
Click here to download complete source code
import java.util.Map;
import java.util.Scanner;
public class EnvironmentVariables {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the name of Environment Variables : ");
String name = scanner.nextLine();
String value = System.getenv(name);
System.out.println(name + " = " + value);
Map < String , String > mapOfEnvironmentVariables = System.getenv();
for(String var : mapOfEnvironmentVariables.keySet()) {
System.out.println(var + " = " + System.getenv(var));
}
}
}
Click here to download complete source code
Output of the program :
