Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Jul 2, 2001

Setting Proxy in Java Code


The java.net package contains classes that deal with connections across the network. If there is a direct connection to the Internet via a modem, various classes like the HttpConnection or the raw Connection class can be used to get a connection to a server on the net.

This approach fails if you are going through a proxy server. To tell the JVM a proxy is installed, system variables need to be set explicitly set using the System class.

What you have to do is basically set three variables. These are:
 
    proxySet
    proxyPort
    proxyHost

This small piece of code shows how to set a proxy before calling the connecting code:
 
//some previous code

    System.getProperties().put(
Irfan Ahmed
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date