Software >> Development >> Languages >> Java >> examples >> How to access URL from java with and without proxy server

Accessing URL without proxy:-

$JAVA_HOME/bin/java -Dhttps.proxyHost=192.168.1.1 -Dhttps.proxyPort=8080 URLReader "https://www.google.com"


Example for http URL via proxy server:-

$JAVA_HOME/bin/java -Dhttp.proxyHost=192.168.1.1 -Dhttp.proxyPort=8080 URLReader "http://www.google.com"


Example for https URL via proxy server:-

$JAVA_HOME/bin/java -Dhttps.proxyHost=192.168.1.1 -Dhttps.proxyPort=8080 URLReader "https://www.google.com"

 

The sample source code for URLReader.java is here