How to set proxy for JVM

August 28, 2017
Java applications connect to the Internet very often. If you want to use the proxy server to connect to the Internet, you need to set your JVM to use the proxy. To do this, you can set:
http.proxyHost and http.proxyPort. These are JVM flags. We will explain how to set them correctly.

JVM flags

You can set them when starting your JVM on the command line. In Windows, you can use a bat file. In Unix a shell script:
The situation is slightly different when you are using containers (such as WebLogic). Then you need to edit the startup scripts which your container provides.

nonProxyHost property

When you don’t want to use the proxy to resolve some local hosts you can use http.nonProxyHosts property. The usage:

Click here to add a comment

Leave a comment: