Many java applications uses http or https connection to access the API.This access can be either outside or within the network. In outside network it has to traverse through internet . Opening an direct internet access in production server is dangerous

So this case internet access should go through proxy settings and all internet traffic can go through proxy configuration . Let see how proxy setting can be applied in java

URL url = new URL("GET_URL");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy server", "port"));
HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);

Proxy server.URL and port needs to be changed. Once this setting is done all the request goes through proxy server. This is similar to the setting we do in browser.