no, this will not work. these are simply properties that can be used by your app. changing them will change the value only in the context of you app, not the computer.

you can usually pass a proxy object to calls that may require it such as this post demonstrates.


even though most of the languages does not allow (or) discourage to change the environment variables through program, you can achieve that with jni in java using setenv() and using processbuilder().

but why do you want to change something for every one from your program? instead change the variables in your program context like setting the proxy server so that it could be effective only for your program run time context. that's how the applications should be designed and programmed.

here is an example, off the top of head.

 public static void main(string[] args) throws exception
        processbuilder processbuilder = new processbuilder("cmd.exe", "/c", "set");
        map<string,string> environment = processbuilder.environment();

        //set the new envrionment varialbes here
        environment.put("proxyset", "true");
        environment.put("http.proxyhost", proxyurl);
        environment.put("http.proxyport", proxyport);

        process process = processbuilder.start();
        bufferedreader inputreader = new bufferedreader(new inputstreamreader(process.getinputstream()));
        string datalog=null;
        while ((datalog = inputreader.readline()) != null)
            //just to see what's going on with process

note: again, discourage the practice of changing environment variables from your program, instead set the required ones for just your context.

Related Query

More Query from same tag