Originally posted by Nate Mattson:
....and that is one of the first reasons I would want to query environment variables. Knowing if your in test, or in production is critical.
Setting system properties when starting a Java program from a command line is easy using the -D option; the program can query by property name:
System.getProperty("thePropertyName");
Referencing the value of an environment variable from a command line (so you can pass it as system property) is possible in Unix and Windows, but the command line syntax varies.
Unix: java -DthePropertyName=$theEnvVariableName
Windows: java -DthePropertyName=%theEnvVariableName%
Maybe this can help...