public static void main(final String[] args)throws Exception {
        final InetSocketAddress socksaddr = new InetSocketAddress("localhost", 1080);
        final PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create()
                .setDefaultSocketConfig(SocketConfig.custom()
                        .setSocksProxyAddress(socksaddr)
                        .build())
                .build();
        try (final CloseableHttpClient httpclient = HttpClients.custom()
                .setConnectionManager(cm)
                .build()) {

            final HttpHost target = new HttpHost("http", "httpbin.org", 80);
            final HttpGet request = new HttpGet("/get");

            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
                    " via SOCKS proxy " + socksaddr);
            httpclient.execute(target, request, response -> {
                System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
            });
        }
    }
How to send a request via SOCKS proxy.

@since 4.1
httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java