How can my Java code read OS environment variables?

environment-variables, java, operating-system

Solution

Try System.getenv(String name)

Problem

This may be a very simple problem, but I couldn't find an answer googleing and I'm in a rush - so I'd appreciate fast code examples. I have an environment variable on the OS I would like to read using Java code. I've tried `System.getProperty`, but that only seems to work for the `-D` variables supplied directly for the JVM. How can my Java code read OS variables?

Original source

Related problems