devxlogo

Setting a Proxy in Java

Setting a Proxy in Java

Let’s assume that we have a proxy at address proxy.host:8888. We can set up this proxy via the JDK 11 HttpClient as follows:

HttpClient client = HttpClient.newBuilder()   .proxy(ProxySelector.of(new InetSocketAddress("proxy.host", 8888)))   .build();

devx-admin

Share the Post: