From http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
The SOCKS protocol, defined in RFC 1928, provides a platform for client server applications to safely pass through the firewall at both the TCP and UDP levels. In this sense, it is much more general than higher level proxies (for example, HTTP or FTP proxies). J2SE 5.0 provides SOCKS support for TCP client sockets.
There are 2 system properties associated with SOCKS:
socksProxyHost for SOCKS proxy hostname
socksProxyPort for port number, default value is 1080
Note that after the prefix this time there is no period ('.'). This is for historical reasons and for backward compatibility. Once the SOCKS proxy server is specified this way, all TCP connections will be made through the proxy server.
Example:
$ java -DsocksProxyHost=socks.mydomain.com GetURL
Here, during code execution, each outgoing TCP socket will go through the SOCKS proxy server at socks.mydomain.com:1080.
Now, what happens when the SOCKS proxy and HTTP proxies are defined? The rule is that settings for higher-level protocols, such as HTTP or FTP, take precedence over SOCKS settings. Thus, in this particular case, when establishing an HTTP connection, the SOCKS proxy settings will be ignored, and the HTTP proxy will be contacted. Consider an example:
$ java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080 -DsocksProxyHost=socks.mydomain.com GetURL
Here the http url will go through webcache.mydomain.com:8080 as the http parameters take precedence. But what about the ftp url? Since no proxy server settings were assigned to FTP, and since FTP is on top of TCP, FTP connection attempts will be made through the SOCKS proxy server at socks.mydomsain.com:1080. If an FTP proxy was specified, then a proxy server would be used instead.