Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中使用Http、Socksproxies?_Java - Fatal编程技术网

如何在java中使用Http、Socksproxies?

如何在java中使用Http、Socksproxies?,java,Java,我的java应用程序需要连接到internet,我在代理服务器后面。我利用休耕地 函数设置代理,但它不起作用 System.getProperties().put("http.proxySet", "true"); System.getProperties().put("http.socksProxyHost", value); System.getProperties().put("http.socksProxyPort", value); 感谢您签出,特别是使用类的答案。请检查系统参数名称

我的java应用程序需要连接到internet,我在代理服务器后面。我利用休耕地 函数设置代理,但它不起作用

System.getProperties().put("http.proxySet", "true");
System.getProperties().put("http.socksProxyHost", value);
System.getProperties().put("http.socksProxyPort", value);

感谢您签出,特别是使用类的答案。

请检查系统参数名称。有两种方法可以做到这一点:

  • 从命令行本身设置系统参数
或者在代码中设置这些参数,如下所示

System.getProperties().put(“http.proxyHost”、“proxyURL”); System.getProperties().put(“http.proxyPort”、“proxyPort”); System.getProperties().put(“http.proxyUser”、“用户名”); System.getProperties().put(“http.proxyPassword”、“password”)


我将PROXY类用作fallows:PROXY PROXY=newproxy(PROXY.Type.SOCKS,newInetSocketAddress(“127.0.0.1”,15667));url=新url(站点地址);httpUrlConnection=(httpUrlConnection)url.openConnection(proxy);但是给出这个错误:当url.openConnection(proxy)停止时,来自SOCKS服务器和MyJava应用程序的错误回复;
java -Dhttp.proxyHost=proxyhostURL
-Dhttp.proxyPort=proxyPortNumber
-Dhttp.proxyUser=userName
-Dhttp.proxyPassword=password YourProgram