I have Java Program which access the Linux Variable(example $VARD
, i have exported the variable as well), I am accessing the variable value using Runtime.getRuntime("echo $VARD")
function. Issue is it prints variable name instead of its value.
Note: I am running this program in Linux server where it has JAVA JDK 1.4 version. I knew we can do that using getenv().get()
function which is available from JDK 1.5..
In general you should use
System.getProperty()
orSystem.getEnv()
.If you are using maven there is another option. You can access environment variables from maven by using
${env.VARIABLE_NAME}
.