Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Http Proxy in an applet

For a java desktop application after we set these properties

System.setProperty("java.net.useSystemProxies","true");
System.setProperty("http.proxyHost", "1.1.1.1");
System.setProperty("http.proxyPort", "8080");

every http connection will be done through the defined proxy.

But for an applet these does not work.(In an applet viewer it does but in a browser it doesnt.) Applet always uses these settings which are defined in control panel\java\network settings\proxy settings.

How can i set the proxy in an applet? (Using proxy class in every opening connection is not a solution for me.)

Applet is signed and compiled with java 1.6

like image 502
e13420xx Avatar asked Jul 13 '11 10:07

e13420xx


1 Answers

I imagine that the real reason that the System properties approach doesn't work is that by the time the applet starts, the Java runtime system has already read the properties and set up the default proxy selector.

Have you tried using ProxySelector? Refer to section 4) of this document.

Of course, this is only likely to work when your applet is a signed applet.

like image 68
Stephen C Avatar answered Oct 17 '22 06:10

Stephen C