I have a java application running in a linux environment. The environment has a http proxy server set using HTTP_PROXY
and HTTPS_PROXY
environment variables.
My java application needs to use a REST API, so I added the VM arg below to use the system proxy.
-Djava.net.useSystemProxies=true
But the java application disregards the proxy and tries to connect to the url directly.
However, if I use below VM args, it works properly.
-Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port> -Dhttps.proxyHost=<host> -Dhttps.proxyPort=<port>
For me, using -Djava.net.useSystemProxies=true
is desirable since I don't have to change the command I use to run the java application when the proxy server is changed.
Any idea why -Djava.net.useSystemProxies=true
is not working?