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.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Don't forget the shell variable _JAVA_OPTIONS
For more properties look here: http://mindprod.com/jgloss/properties.html
With a current JVM you can pass the proxy host and port using Java properties
See http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
For username and password, what about:
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.
You can use this script to automatic enviroment passing to java application
This is an intelligent script, if you enable nmap section, it is detecting proxy up or down status , if it is up status it is using proxy if it is down status it is using direct connection..
With this script you can connect your app with enviroment settings or overwrite enviroment or with proxy service up detection method , the application selects direct or proxy mode
This is an intelligent connection bash shell script
Ofcouse if you don't enable nmap service up/down section, this is an simple proxy enviroment or your overwrite value for your application
It is producing automaticly proxy connection command line then running your java application
This is script's code: