Proxy Configuration - Online Code


When, I was developping a network based application in Java. I face a lot of problems to configure network, specially the Proxy Configuration. After a lot of effort finally, I got the solution. Here is the code fragment, by using this code fragment you can easily configure proxy setting in your Java Application.

Source Code

		// Define the proxy settings as required.
       Properties systemSettings = System.getProperties();
       systemSettings.put("http.proxyHost", "Put your Proxy Host Address here");
       systemSettings.put("http.proxyPort", "Put your Proxy Port Adress here: by default it is 8080");

If your network connection have "Username" and "Password" authentication, then you have to use this code fragment also in your application.

		Authenticator.setDefault(new Authenticator()

           protected PasswordAuthentication getPasswordAuthentication()
	           return new PasswordAuthentication("Your UserN
... (login or register to view full code)

To view full code, you must Login or Register, its FREE.

Hey, registering yourself just takes less than a minute and opens up a whole new GetGyan experience.


No comment yet. Be the first to post a comment.