How can I get System variable value in Java?

raja picture raja · Feb 10, 2009 · Viewed 215.2k times · Source

How can I get the System Variable value which is present in

MyComputer -> Properties -> Advanced -> Environment Variables -> System Variables

in Java?

Edit

I have used System.getenv() method.

It is printing value if I give

System.out.println(System.getenv("JAVA_HOME"));

and it is showing null value if I try the same for system variable created by me

System.out.println(System.getenv("DBE"));

Answer

Rob picture Rob · Feb 10, 2009

Use the System.getenv(String) method, passing the name of the variable to read.