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

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

问题描述

我正在考虑一个简单的 Java 应用程序(命令行),它连接到互联网以下载 XML 文件,问题是我的 Ubuntu 正在使用代理通过用户名和密码(通过 http_proxy="http://<用户名>:@:<端口>").所以我的问题是,是否可以编写一个 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天全站免登陆