While `System.getenv` exists in Java since day 0, it did not return any meaningful results (but threw exceptions) in Java 1.4 or older. I don't know if you want to handle/support these ancient versions; if yes, you can have a look how the expand_path command handles it (by hardcoding values) :)