Setting JVM/JRE to use Windows Proxy Automatically

前端 未结 6 1371
[愿得一人]
[愿得一人] 2020-11-28 06:29

I did see the question about setting the proxy for the JVM but what I want to ask is how one can utilize the proxy that is already configured (on Windows).

Here is a

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 06:52

    try{
        System.setProperty("java.net.useSystemProxies", "true");
        String prx = ProxySelector.getDefault().select(new URI("http://www.google.com")).get(0).address().toString();
        JOptionPane.showMessageDialog(null, prx);
    } catch(Exception e){
        JOptionPane.showMessageDialog(null, "no proxy");
    }
    

提交回复
热议问题