We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

In Java we can read the environment variables using System.getEnv().
System.getEnv() was introduced in the very begining of Java. deprecated in JDK 1.2 and reinstated in JDK 1.5.
we can use the following method to read environment variables. 
 
  public void readEnvVariables()
   {
       Map<String, String> envVariables = System.getenv(); 
      Set stEnvVariables = envVariables.entrySet();
      Iterator itrEnvVariables = stEnvVariables.iterator();
 
      while(itrEnvVariables.hasNext())
{
      Map.Entry mpEnvVar = (Map.Entry) itrEnvVariables.next();
   System.out.println(mpEnvVar.getKey()+"="+mpEnvVar.getValue());
 
}
   }


Related Tags:

Java

Author: Tanmayee Sahoo

top

Java

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login