java Java中如何获取系统HTTP代理配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/226677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:31:34  来源:igfitidea点击:

How to get the system HTTP proxy configuration in Java

javanetworkingproxy

提问by Auron

Is it possible to get the system proxy configuration in Java?

是否可以在 Java 中获取系统代理配置?

In the Java Control Panel, you can set a proxy configuration. How can I access to that proxy configuration in order to open URL connections behind a proxy?

在 Java 控制面板中,您可以设置代理配置。如何访问该代理配置以打开代理后面的 URL 连接?

采纳答案by Anton K

oh, just look at thatquestion. there was a sample with a solution.

哦,看看那个问题。有一个带有溶液的样品。

currently all samples I've seen use SUN's undocumented APIs (com.sum packages), which result in warnings at compile time...

目前我见过的所有示例都使用 SUN 未公开的 API(com.sum 包),这会导致在编译时出现警告......

回答by ddimitrov

The Java Plugin gets it from the system settings. If the app has to be started as either applet or webstart you can use the webstart/applet APIs for this. Otherwise you have to use native code. Look at the various JniWrapper's WinPack and the JDIC libs - they might have done the heavy lifting for you.

Java 插件从系统设置中获取它。如果应用程序必须作为小程序或 webstart 启动,您可以为此使用 webstart/applet API。否则,您必须使用本机代码。查看各种 JniWrapper 的 WinPack 和 JDIC 库——它们可能已经为您完成了繁重的工作。