System properties
June 4th, 2004
This article about System.getProperty (via Erik)blew me away. I was utterly convinced that System.getProperty() gave me everything I've set in my environment, that I had to try it out. And I was quite baffled to see that the author was right.
However, his proposed solution threw a "java.lang.IllegalArgumentException: Malformed \uxxxx encoding." on my Windows XP machine.

April 21st, 2008 at 10:17 PM Well, the javadoc for java.lang.System tells you that you were wrong. It has a depricated method getenv to get the OS environment variables. I just tried it and it throws an Error. The preferred method is to pass the environment variables you need to the java runtime using the -D switch. (And most of the times it's sensible, the only problem I can see is when you don't start your application with a shell script but rather use an indirect way, like launchers, file associations, etc.)
April 21st, 2008 at 10:17 PM The javadoc says: "Gets the system property indicated by the specified key." I was just amazed that a "system property" is not the same as an "OS environment variable".
April 21st, 2008 at 10:17 PM System.getenv works again in 1.5, and there's also System.setenv.
April 21st, 2008 at 10:17 PM Odd how people think differently. I would've never expected os env variables to be propagated as system props. In fact I remember digging ant cvs after being intrigued by how their trick DID allow to read those variables (through the same exec hack)