Wednesday, May 13, 2009

Setting java proxy

I had many problems with internet proxy. And I forgot every time when I want to create a file that access pass proxy.

This code is a method to set proxy:

private static void setProxy() {
Properties systemSettings = System.getProperties();
systemSettings.put("proxySet", "true");
systemSettings.put("http.proxyHost", "server_host");
systemSettings.put("http.proxyPort", "server_port");
}

And with the java command, you can use this to pass the proxy
$ java -DproxyHost="server_host" -DproxyPort="server_port" pkg.JavaClass



Have a fun

1 comment:

  1. Hi,

    We have just added your latest post "Setting java proxy” to our Directory of Credit Cards. You can check the inclusion of the post here . We are delighted to invite you to submit all your future posts to the directory for getting a huge base of visitors to your website and gaining a valuable backlink to your site.


    Warm Regards

    Credit car-d Team

    http://www.creditca-rd.info

    ReplyDelete