I'm looking for a form on how to get system proxy information in Java under Windows, but I only found one way. But this does not work for me.
public static void main(String[] args) throws Throwable { System.setProperty("java.net.useSystemProxies", "true"); System.out.println("detecting proxies"); List<Proxy> pl = ProxySelector.getDefault().select(new URI("http://ihned.cz/")); for (Proxy p : pl) System.out.println(p); Proxy p = null; if (pl.size() > 0) //uses first one p = pl.get(0); System.out.println(p.address()); System.out.println("Done"); }
When I run the program, I get:
detecting proxies DIRECT null Done
Java means that I am located directly on the Internet. But this is wrong. I am for the proxy. I can not get a solution for my computer.
java proxy networking
KT Schnikow
source share