I've got an easier way. Look at this:
public class Tester {
public static void main(
String[] args) {
System.out.println(System.getProperty("testEnvVal"));
}
}
The String testEnvVal is the Env val you want.
Then you can read it from the system by using:
java -DtestEnvVal=%testEnvVal% Tester
java -DtestEnvVal=$testEnvVal Tester
I hope that helps.
Erik