The System.getenv()
method returns an unmodifiable view of the environment variables. You cannot use it to set environment variables like you're doing here.
The only time you can "set" environment variables is when you are creating an environment for a child process, using the ProcessBuilder
class or the Runtime.exec
method, but even then you are not modifying your copy of the environment.