How do you set environment variables in Java? You can't, because you shouldn't want to do that. Of course, I would really, really like to do that.
Perl is the only truly portable language I know. (I know there are others; I just don't know them.) It manages to do things as similarly as possible across an incredible range of platforms.
It seems that with JNI you could extend Java to do a lot of things it doesn't want to do. Most of these could be done quite portably, too. [Not being able to do them portably is the only reason I can see for these features to be kept out of Java itself.]
So, if I had a little extra time, I'd like to spend it releasing a jar full of classes to support simple portable extra features for Java, like:
Copying/renaming a file without having to read it block by block
Setting environment variables
Changing the current working directory
I guess if I was really flush for time I'd go see what it would take to get this going in the Java Community Process. Or fork the JDK.