I am thinking of a simple Java appplication (command line) that connects to the internet to download a XML file, the problem is that my Ubuntu is using a proxy to connect to internet with username and password (through http_proxy ="http://<username>:<pwd>@<ip>:<port>"
). So my question is, could it be possible to write a java app to use http_proxy
variable? Instead of programmatically setting http proxy and host in every app I will write.
views:
346answers:
4
+1
A:
With a current JVM you can pass the proxy host and port using Java properties (java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080 -Dhttp.noProxyHosts=”localhost|host.mydomain.com” GetURL ) - http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
Username and password examples http://www.rgagnon.com/javadetails/java-0085.html http://www.developer.com/java/other/article.php/1551421/Questions-on-HttpURLConnection-and-Proxies.htm
2010-03-16 01:33:17
A:
in http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html there is no command to pass proxy username and password to JVM.
rbbeltran
2010-03-15 01:01:41
A:
For username and password, what about -Dhttp.proxyUser=username -Dhttp.proxyPassword=supersecret ?
Stephane
2010-05-21 09:14:04
A:
Dont forget the Shell Variable _JAVA_OPTIONS
export _JAVA_OPTIONS='-Dhttp.proxyPort=cache.com -Dhttp.proxyPort=3128'
for property stuff look to the excellent http://mindprod.com/jgloss/properties.html
wiki1000
2010-06-03 13:58:35