# java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=80 JavaClass
System.setProperty("http.proxyHost", "myProxyServer.com"); System.setProperty("http.proxyPort", "80");
System.setProperty("java.net.useSystemProxies", "true");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("123.0.0.1", 8080)); URL url = new URL("http://www.yahoo.com"); HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy); uc.connect();
How do I configure proxy settings for Java? Java HTTP Proxy Settings HTTP Proxy setting in Java How to Set JVM Proxy Setting Without Touching the Code