Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java app behind proxy to use http_proxy variable in linux

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.

like image 731
rbbeltran Avatar asked Mar 12 '10 02:03

rbbeltran


People also ask

Does Java use Http_proxy?

Java provides proxy handlers for HTTP, HTTPS, FTP, and SOCKS protocols. A proxy can be defined for each handler as a hostname and port number: http. proxyHost – The hostname of the HTTP proxy server.


1 Answers

Don't forget the shell variable _JAVA_OPTIONS

export _JAVA_OPTIONS='-Dhttp.proxyHost=cache.com -Dhttp.proxyPort=3128'

For more properties look here: http://mindprod.com/jgloss/properties.html

like image 133
wiki1000 Avatar answered Sep 16 '22 16:09

wiki1000