Tuesday, November 9, 2021

Proxy HTTP/HTTPS Request From Java Application

Proxy HTTP/HTTPS Request From Java Application






Problem: In some client environment, according to organization policy, http request should go through the proxy server. If Java application need to access outside HTTP or HTTPs url, we have to pass them through the proxy.

Solution: We can set proxy server IP and port in java bat or .sh file as a parameter.

HTTP Proxy

"D:\App Servers\Feeder-NEW\jdk1.8.0_151\bin\java" -Xmx2048m -Xms2048m -DAlert=true -Dhttp.proxyHost=192.168.33.34 -Dhttp.proxyPort=8080 -DExchange=A -DLogFeed -classpath SVR_-9.10.020.jar;.\lib\* com.regional.feeder.xstream.com

HTTPS Proxy

"D:\App Servers\Feeder-NEW\jdk1.8.0_151\bin\java" -Xmx2048m -Xms2048m -DAlert=true -Dhttps.proxyHost=192.168.33.34 -Dhttps.proxyPort=8080 -DExchange=A -DLogFeed -classpath SVR_-9.10.020.jar;.\lib\* com.regional.feeder.xstream.com

Reference URL: 

https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html


No comments:

Post a Comment