代理后面的Java应用在Linux中使用http_proxy变量 [英] Java app behind proxy to use http_proxy variable in linux

查看:538
本文介绍了代理后面的Java应用在Linux中使用http_proxy变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在考虑一个简单的Java应用程序(命令行),该应用程序连接到互联网以下载XML文件,问题是我的Ubuntu使用代理通过用户名和密码(通过http_proxy ="http://<username>:<pwd>@<ip>:<port>")连接到互联网. .所以我的问题是,是否可以编写一个Java应用程序以使用http_proxy变量?不用在我将要编写的每个应用程序中以编程方式设置http代理和主机.

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.

推荐答案

不要忘记shell变量_JAVA_OPTIONS

Don't forget the shell variable _JAVA_OPTIONS

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

有关更多属性,请点击此处: http://mindprod.com/jgloss/properties.html

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

这篇关于代理后面的Java应用在Linux中使用http_proxy变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆