Hello Chris,

native Windows applications "just work" because they access native
Windows APIs to read the proxy settings, which are probably stored
somewhere in the Windows registry. Browsers and the Java Plugin
for browsers are native Windows applications, and therefore can do
just that.

The only solution I can imagine right now is for you to write JNI code
that looks up the appropriate keys in the registry. Which means you'll
have to distribute a DLL along with the Java application.

Wait, here is another idea: you could write a startup script that does
the proxy settings lookup, then passes the settings through -D
definitions as system properties, which can be accessed by your
Java application. That's a bit less ugly than calling native code
from within the app. The proxy settings for the HttpURLConnection
of the JDK are expected as system properties, too.

hope that helps,
  Roland





"Chris Brown" <[EMAIL PROTECTED]> 
22.10.2004 10:18
Please respond to
"Commons HttpClient Project"


To
[EMAIL PROTECTED]
cc

Subject
Auto-detecting proxy settings in a standalone Java app






Hello,

I would like to perform a simple request against a HTTP server in an 
application that will be deployed to customers with a wide variety of 
network configurations.  The application won't be deployed as an applet or 

within Java Webstart, but will require JDK 1.4.2+ as the platform.  The 
target audience are all Windows users.

I've searched the HTTPClient archives and also the forums on Sun's Java 
Developer site.  The only useful links were:

http://forum.java.sun.com/thread.jsp?forum=30&thread=364342
http://www.mail-archive.com/[EMAIL PROTECTED]/msg05349.html


I get the following error when trying this out:

java.io.IOException: Proxy service provider is not yet set
at 
com.sun.java.browser.net.ProxyService.getProxyInfo(ProxyService.java:40)

...so I assume this only works within Webstart or an applet.

Is there any way I can *automatically* retrieve the user's browser 
settings, 
even if requires using JNI or JNIWrapper for example ?  At least the proxy 

host and port, even better if it can automatically enable login (or even 
provide me with enough info to use the NTLM features of HTTPClient, if 
required by the customer's environment).

Manual proxy configuration generates *way* more support costs at present 
than anything else in the project.  It's annoying to be disadvantaged in 
this way, when most native Windows applications "just work"...

Thanks in advance,
Chris Brown

_________________________________________________________________
Bloquez les fenêtres pop-up, c'est gratuit ! http://toolbar.msn.fr


---------------------------------------------------------------------
To unsubscribe, e-mail: 
[EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]


Reply via email to