views:

946

answers:

1

I would like to configure Java proxy settings on Solaris to use a proxy script.

I have found instructions for making the settings on a Windows machine using the Java control panel, but am having trouble finding where/how to make the same setting changes on a Solaris Java install.

I would like to use the proxy script, rather than manually setting proxy info per connection, or using a single proxy. I have a need to leverage multiple proxies for different types of URLs.

+2  A: 

The article you have provided is about the the Java Plug-in (i.e. the Java runtime environment for browsers) that can be configured through the Java Plug-in Control Panel and applies to:

Platform(s): All Platforms

So, it's really not Windows specific.

Now, if your question is "How do I start the Java Plug-in Control Panel on Solaris", the answer is:

You can run the Control Panel by launching the ControlPanel executable file. In the Java 2 SDK, this file is located at

<SDK installation directory>/jre/bin/ControlPanel

For example if your Java 2 SDK is installed at /usr/j2se, launch the Control Panel with this command:

/usr/j2se/jre/bin/ControlPanel

But usually people are not using Solaris for surfing so I'm not really sure that this is what you're looking for (actually, I didn't understand clearly what you want to do).

If you are going to connect programmatically, please note that Java uses two system properties to designate a proxy: http.proxyHost and http.proxyPort. For applets, these are automatically set to use the browser's settings. However, in an application you need to set them yourself:

Properties props = System.getProperties();
props.put("http.proxyHost", "proxyhostname");
props.put("http.proxyPort", "proxyhostport");


As per comment, my understanding is that you want to use a PAC file. To use a Proxy auto-config from Java code and/or Ant with Java 1.5+, you can configure the proxy at the "OS level" and set the system property java.net.useSystemProxies to true (see section 4) ProxySelector of Java Networking and Proxies) or the -autoproxy option for Ant. This will make the Java code and/or Ant use the OS proxies.

To setup your Solaris host, if you are using Gnome 2.X, you can configure proxies globally through the user interface (System > Preferences > Network Proxy). If you're not using Gnome, setup the following environment variable:

export http_proxy=http://username:password@proxy_url

To specify a list of non proxy hosts (if necessary), setup this variable (this is an example):

export no_proxy=localhost,127.0.0.0/8,*.local
Pascal Thivent
What I am looking for is a way to delegate the logic for selecting the appropriate proxy to an existing proxy script, so that I don't have to replicate and maintain the logic in code. I will be running some JEE code on a Solaris server and/or ANT with -autoproxy switch to fetch HTTP resources through different proxies. I haven't had a chance to test it yet, but suspect that the ControlPanel settings will work.
Mads Hansen
I think that you need to configure your Solaris host (not the Java Plug-in) to use your proxy PAC file globally. Then, set the `java.net.useSystemProxies` system property in your Java code (in the case of Ant, this is what the `-autoproxy` option does). This tells the JVM to use the system proxy settings. See section 4) ProxySelector of http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
Pascal Thivent
So, you appear to be correct in that settings for the ControlPanel do not appear to affect normal JRE HTTP operations, even with -Djava.net.useSystemProxies=true at startup. I'm at a loss for how to configure Solaris to use the autoproxy PAC file/URL. Google isn't turning up anything. Maybe that should be a separate SO question, or maybe something for ServerFault...
Mads Hansen
I've added some details to use the PAC file.
Pascal Thivent