How do I configure proxy settings for Java in Sola

2019-02-15 07:00发布

I would like to configure Java proxy settings on Solaris to use a Proxy Auto Config (PAC) scriptt.

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 Auto Config (PAC) 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条回答
干净又极端
2楼-- · 2019-02-15 07:36

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
查看更多
别忘想泡老子
3楼-- · 2019-02-15 07:47

Sadly the system proxy selector does not handle PAC/WPAD/JS specifications, confirmed by my testing with Windows or MacOS X. Even on Java6, which includes a JavaScript interpreter.

I'm hoping proxy-vole http://code.google.com/p/proxy-vole/ may do the trick.

查看更多
登录 后发表回答