Integrations / Language

Use Proxys with Java

Use Proxys with Java's HttpClient.

Steps

  1. Set a ProxySelector and an Authenticator for the proxy credentials.
  2. Allow Basic auth for HTTPS tunnels: -Djdk.http.auth.tunneling.disabledSchemes=""
Java
HttpClient client = HttpClient.newBuilder()
  .proxy(ProxySelector.of(new InetSocketAddress("gw.proxys.co", 8000)))
  .authenticator(new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication("USERNAME-country-us", "PASSWORD".toCharArray());
    }
  }).build();

Before you start

Replace USERNAME and PASSWORD with a sub-user's credentials from the dashboard. Change -country-us to the country you need, or remove it for a random location. See targeting options for city, ASN and sticky sessions.

Try 1 GB for $1