Pin It

How to query Environment Variables through a Java Program ?.

Program to demonstrate how to query Environment Variables through Java.





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 : 


 
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot