Jigish Chawda
Jigish Chawda

Reputation: 2188

change browser's Internet settings using java code

I am trying to spawn a browser using a small java code

String command="rundll32 url.dll,FileProtocolHandler http://www.google.com"
Process process = Runtime.getRuntime().exec(command);

The above thing works fine. However there certain difficulties I am facing.

  1. I need to change the proxy settings of the browser.
  2. Since the above code spawns the default web browser, first of all I am not able to find the default browser. Secondly, how do I change the proxy settings for that particular browser?

I tried to implement following code, but its not working:

System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8080");

But what I can understand is that its for JVM and not for the browser. And I need to change this for a particular browser.

Thanks and regards.

Upvotes: 0

Views: 1044

Answers (1)

Surasin Tancharoen
Surasin Tancharoen

Reputation: 5860

My answer may not fully help you but it can guide you a bit.

There is totally not related to System.setProperty. This method sets VM system property.

What you are trying to do is 'change Windows property'. Then you should find solution by Windows command (not by java) as you already did:

String command="xxxx"
Process process = Runtime.getRuntime().exec(command);

Upvotes: 2

Related Questions