Java中的代理服务器配置 [英] Proxy Server Configuration in Java

查看:104
本文介绍了Java中的代理服务器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我使用代理编写了用于互联网连接的代码.

Hi.

I written the code for internet connection using proxy..

public static void main(String[] args) 
    {
        
    System.getProperties().put("proxySet", "true");
    System.getProperties().put("http.proxyHost", "172.16.11.30");
    System.getProperties().put("http.proxyPort", "808");
    System.getProperties().put("http.proxyUser","admin");
    System.getProperties().put("http.proxyPassword","admin");
   
    try
    {
        String strUrl1 = "http://www.google.com";
        URL url = new URL(strUrl1.toString());
        URLConnection conn = url.openConnection(); 
        ReturnValue(conn);
    }
    catch(Exception e)
    {
        System.out.println("Exception During the URL Operation"+e);
    }

       
    }


这给出了运行时错误,如:

ReturnValuejava.io.IOException期间的异常:服务器返回的HTTP响应代码:407表示URL:http://www.google.com


我的Poxy服务器IP:172.16.11.30
端口:808


This is gives run time error as :

Exception During ReturnValuejava.io.IOException: Server returned HTTP response code: 407 for URL: http://www.google.com


My Poxy server Ip:172.16.11.30
port:808

推荐答案

您好.

我认为JVM不了解您的代理设置.

我找到了一些有关如何在Java中设置代理连接的文档.真奇怪,它没有提到您的解决方案.
尝试这样的事情:
Hello.

I think that the JVM doesn''t know about your proxy settings.

I found some documentation about how to set up proxy conenction in Java. That''s strange, that it doesn''t mention your solution.
Try something like this:
System.setProperty("http.proxyHost", "172.16.11.30");
System.setProperty("http.proxyPort", "808");
System.setProperty("http.proxyUser","admin");
System.setProperty("http.proxyPassword","admin");



这是我在其中找到这些东西的文档: Oracle Docs-代理



This is the document where I found this stuff: Oracle Docs - Proxies


这篇关于Java中的代理服务器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆