The argument you pass as the host to factory.createSocket(host,port)
must not have the protocol prepended to it. It should simply be google.com
.
The reason is that Java is going to take that host
parameter and pass it as input to a DNS lookup. If you were to type host https://google.com
on the command line, you'd get a similar failure.