ADC Home > Reference Library > Technical Q&As > Legacy Documents > Java >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Specifying Proxy Settings


Q: I have a Java application that needs to use a proxy server for connections to the Internet. How do I specify these settings in my application?

A: Java networking classes use System properties to route network traffic through proxy servers. MRJ (version 2.2 or later) automatically uses the settings in the Internet Control panel to continually update the System properties. By far, the best thing to do is have the use the proxy information in the Internet Control panel.

You can set these properties using JBindery, MRJAppBuilder, or programmatically, but you run the risk that MRJ will overwrite them.

The image below illustrates how the Internet control panel settings map to those in JBindery:

Proxy

Here is a complete table of how these settings map:

Internet Control Panel Setting
JBindery Setting
Java System Property
Web Proxy (checkbox) HTTP proxy (checkbox) proxySet
Web Proxy (text) HTTP proxy (text) proxyHost
Web Port HTTP Port proxyPort
FTP Proxy (checkbox) FTP proxy (checkbox) ftpProxySet
FTP Proxy FTP proxy ftpProxyHost
FTP Port FTP Port ftpProxyPort
  Firewall (checkbox) firewallSet
  Firewall firewallHost
  Firewall Port firewallPort
Bypass Proxy Servers http.nonProxyHosts

The Proxy settings in the Internet Control Panel are accessible from the Firewall page of the Advanced tab. JBindery settings can be specified from the Security page.

If you wish to configure your proxy settings programmatically, you need to use Java's standard property mechanism.


import java.util.*;
class SystemProperties
{
    public static void main(String args[])
    {
        Properties systemproperties = System.getProperties();
        systemproperties.put("firewallHost",
                             "web.proxy.nl.com"); // firewall proxy server
        systemproperties.put("firewallPort",
                             "140");              // firewall port #
        systemproperties.put("firewallSet","true");
        systemproperties.put("proxyHost",
                             "http.proxy.nl.com");// http proxy server
        systemproperties.put("proxyPort",
                             "180");              // http port #
        systemproperties.put("proxySet","true");
        systemproperties.put("ftpProxyHost",
                             "ftp.proxy.nl.com"); // ftp proxy server
        systemproperties.put("ftpProxyPort",
                             "110");              // ftp port #
        systemproperties.put("ftpProxySet","true");
        systemproperties.put("http.nonProxyHosts",
                             "apple.com|netscape.com");
                                                  // proxy bypass sites
        System.setProperties(systemproperties);
    }
}

To modify your proxy settings using MRJAppBuilder, add the settings directly in your properties file. Here's an example:

proxySet = true
proxyHost = http.proxy.nl.com

For more information on system properties in Java, please visit Sun's web pages.

For more information on MRJAppBuilder, see the document About MRJAppBuilder that ships with the MRJ 2.2 SDK in Tools:Application Builders:MRJAppBuilder. For more information on JBindery, consult About JBindery that ships with the MRJ 2.2 SDK (and earlier) in Tools:Application Builders:JBindery.

[Apr 24 2000]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.