i assumed that System.getProperties() also returns properties set by us in the OS variables. especially as i read that on MAC that is the only way to send options to java as program arguments are not supported.
but it seems we must send user properties as -DpropName=value1
even though the batch program starting java can see the OS property we are interested in.
if anyone has mac - is this the case with java on mac too?
shouldn't java pass us all OS properties? it does initialize user.dir , user name etc from windows so why not take all?
Because these were not regarded as necessary. Since Java 5.0 you can use System.getenv() or System.getenv(String property) for this. Actually you could use the latter before Java 5.0 as well although it was deprecated in Java 1.4.
Tushar Kapila wrote:especially as i read that on MAC that is the only way to send options to java as program arguments are not supported.
Where did you read that? Maybe you didn't understand correctly what was meant? You can pass arguments to a Java program on a Mac when running it from the command prompt just like on Windows, Linux or other operating systems.
Works fine on my Mac:
> javac Example.java > java Example hello world args = [hello, world]