Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe for all free courses

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 : 


 
 
© 2021 Learn Java by Examples Template by Hubberspot