To setup a proxy to be used by Maven only, you need to have it defined in the settings.xml file.
This file is located in [USR_HOME]\.m2 directory (C:\Documents and Settings\[USERNAME]\.m2 for Windows users).
Here’s an example of the file:
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>[PROXY SERVER]</host>
<port>[PROXY PORT]</port>
<username>[PROXY USERNAME]</username>
<password>[PROXY PASSWORD]</password>
<nonProxyHosts>www.website1.com|*.website2.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
To setup a proxy to be used for a Java application:
System.getProperties().put("http.proxyHost", [PROXY SERVER]);
System.getProperties().put("http.proxyPort", [PROXY PORT]);
System.getProperties().put("http.proxyUser", [PROXY USERNAME]);
System.getProperties().put("http.proxyPassword", [PROXY PASSWORD]);
To display the proxy server used for a particular URL:
URL url = new URL("http://www.treasurydirect.gov/xml/CPI_20090814.xml");
System.out.println(ProxySelector.getDefault().select(url.toURI()));
Update Dec. 7, 2009: Proxy setup for Subversion command line and subclipse plugin (eclipse).
You should have a file named ‘servers‘ under C:\Documents and Settings\[USR_HOME]\Application Data\Subversion.
The file has pretty good inline documentation.
In my case, at the end of the file, I modified the following lines under [global] group:
[global]
http-proxy-host = [PROXY SERVER]
http-proxy-port = [PROXY PORT]
#http-proxy-username = [PROXY USERNAME]
#http-proxy-password = [PROXY PASSWORD]
http-compression = no
http-auth-types = basic;digest;negotiate