I turn out used a tricky way to resolve this. See the example below. It forks a system command (depends on OS architecture) to echo back the value. Then I can read the env variable content from the output. Anyway, it is not good way but it solves the problem.
Runtime rt = Runtime.getRuntime();
Process p;
InputStream is;
int j;
byte outbyte[] = new byte[1024];
String outline;
try {
if (System.getProperty("os.arch").equals("x86")) {
p = rt.exec("cmd /c echo %AA_HOME%"); // For Windows
} else {
p = rt.exec( "myGetEnv.ksh AA_HOME" ); // For Unix
}
p.waitFor();
is = p.getInputStream();
j = is.read( outbyte, 0, outbyte.length );
outline = new String( outbyte, 0, j ).trim();
System.out.println( "AA_HOME=" + outline );
} catch (Exception e) {
e.printStackTrace();
}
BTW, somehow I can't just put a "echo $AA_HOME" or "sh -c \"echo $AA_HOME\"" in the UNIX clause. Can someone help ?
Thanks.
Jim