====== 在Java程序中如何设置代理 ====== ===== http代理设置 ===== System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", "172.31.170.14"); System.getProperties().put("proxyPort", "8080"); 如果上面的不行,用下面这段: System.getProperties().setProperty("http.proxyHost", Const.proxyHost); System.getProperties().setProperty("http.proxyPort", ""+Const.proxyPort); ===== https代理设置 ===== 当然还可以设置https代理,如果证书有添加进去(Java\jdk1.6.0_14\jre\lib\security),需要指定证书 System.getProperties().setProperty("https.proxyHost", "10.85.40.153"); System.getProperties().setProperty("https.proxyPort", "8000"); System.setProperty("javax.net.ssl.trustStore", "ssl/ca.crt");