score:0
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.
score:1
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");
processbuilder.redirecterrorstream(true);
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
system.out.println(datalog);
}
}
note: again, discourage the practice of changing environment variables from your program, instead set the required ones for just your context.
Source: stackoverflow.com
Related Query
- Changing OS proxy settings using java
- Maven plugin not using Eclipse's proxy settings
- Can detect system Proxy Settings in Java application, but not in JUnit
- Using web proxy with Java 8 JAX-RS RESTEasy clients
- proxy authentication required in azure table using java
- Changing some Eclipse preferences using java
- using eclipse's proxy settings for maven's dependency solving
- How do I configure the proxy settings so that Eclipse can download new plugins?
- How do you develop Java Servlets using Eclipse?
- Java "constant string too long" compile error. Only happens using Ant, not when using Eclipse
- Java in Eclipse: Where do I put files on the filesystem that I want to load using getResource? (e.g. images for an ImageIcon)
- How do you convert WSDLs to Java classes using Eclipse?
- How to debug Java code when using ANT script in Eclipse
- Is there any way of configuring Eclipse IDE proxy settings via an autoproxy configuration script?
- configuring existing eclipse java project to build using gradle
- Why do I get message: "Unhandled event loop exception Java heap space" in Eclipse when using javascript autocomplete?
- Eclipse: How to share Java compiler errors/warnings settings across entire team
- Using Telegram API for Java Desktop App?
- Is there any way I can write (copy-paste) nicely-formatted SQL queries in Java string literals using Eclipse?
- Simple program to call R from Java using Eclipse and Rserve
- Kotlin And Java In The Same Project Using Eclipse IDE
- Changing Java Version From Within Eclipse
- Is it possible to build a java project only once using eclipse and share?
- Using Eclipse Java Compiler (ecj) in maven builds
- How to quickly find the main() in java project using eclipse ?
- Using JUnit 5 with Java 9 without Maven or Gradle
- Eclipse Java project build path using variables
- Java Better alignment of fields declarations using Eclipse
- Indenting Java source files using Eclipse
- Best way to debug Java web application packaged as a WAR using Eclipse and Maven?
More Query from same tag
- How to solve a cyclic project dependency in Eclipse. Any way to make one of the dependencies runtime only?
- Again! In Ubuntu 32 bit: Eclipse can't execute appt in Android sdk
- Eclipse git cannot finish rebase
- Brand new Eclipse plugin project riddled with errors
- Why am I unable to install eclipse hat am I doing wrong?
- Why is Eclipse's Android Device Chooser not showing my Android device?
- How to create an Eclipse folder resource filter in Java
- Android and Eclipse, ABI type
- Add external jars globally
- Why can I not catch this FileNotFoundException?
- Eclipse formatter not applying
- Access to servlet logs on localhost (jetty) when developing app for Google Application engine
- Broken built tools in android SDK manager (missing aapt.exe )
- Creating new keystore in eclipse
- Eclipse becomes unresponsive if used with TESTNG debug option
- Eclipse PHP PDT Vaildation issues with required files
- How can i import a Eclipse launch-group configuration into another workspace along with project
- How to set fastTime of a java.util.Date?
- How to get Eclipse Console to hyperlink text to source code files?
- Android, Run application without emulator or any device
- File system regular expression search tool
- How to reflect modified abstract syntax tree in JDT back to original java source file.?
- Class reference is taken from different jar
- Does Eclipse have the ability to remove all references to a class when the class is removed?
- Missing file halts boy's first encounter with OGRE3D!
- Android Development with Device
- adding c/c++ source file in eclipse
- Start up errors with Oracle Weblogic Server plugin for Eclipse Luna
- Eclipse plugin: Using components of another perspective
- Eclipse and Tomcat stopped halting on errors