I want my Java program to use the system\'s proxy configuration. Accordingly, I used the code found in many places, such as this answer, to set java.net.useSystemProxi
I could load Proxy Auto-Config (PAC) file on Java. Please see below codes and package. I hope this would what you were looking for:
import com.sun.deploy.net.proxy.*;
.
.
BrowserProxyInfo b = new BrowserProxyInfo();
b.setType(ProxyType.AUTO);
b.setAutoConfigURL("http://yourhost/proxy.file.pac");
DummyAutoProxyHandler handler = new DummyAutoProxyHandler();
handler.init(b);
URL url = new URL("http://host_to_query");
ProxyInfo[] ps = handler.getProxyInfo(url);
for(ProxyInfo p : ps){
System.out.println(p.toString());
}
You already have a [com.sun.deploy.net.proxy] package on your machine! Find [deploy.jar] ;D