String variable = System.getenv("PATH");
System.out.println(variable);
In Java 1.5, a new method was introduced to allow you to discover all of the environment variables defined in the system. The following example uses the new method to print all of the environment variables and their values:
Map
That's it.