How to use proxies in Java code

Before using our proxies, ensure that your server IP address is authorized via the proxy control panel.

Sample code for using proxies in Java code:

 

import java.net.*;
import java.util.Scanner;

 

class ProxyTest {
  public static void main(String[] args) throws Exception {
    InetSocketAddress proxyAddress = new InetSocketAddress("1.1.1.1", 8800); // Set proxy IP/port.
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);

    URL url = new URL("http://checkip.instantproxies.com/");
    URLConnection urlConnection = url.openConnection(proxy);
    Scanner scanner = new Scanner(urlConnection.getInputStream());
    System.out.println(scanner.next());
    scanner.close();
  }
}

  • 446 Users Found This Useful
Was this answer helpful?

Related Articles

How to order proxies from InstantProxies.com

1. Go to instantproxies.com, select your proxies/purpose, and click Test Now 2. Click Start...

How to use the InstantProxies.com Control Panel

1. Don't know your admin panel login? Find it in the client area2. Sign into the admin panel at...

How to use proxies in Internet Explorer

1. Open Internet Explorer and click Tools > Internet Options 2. Under the Connection tab,...

How to use proxies in the Chrome Browser

1. Open Chrome and navigate to chrome://chrome/settings (or select Tools > Settings) 2....

How to use proxies in the Firefox Browser

1. Open Firefox and select Tools > Options 2. Under the Advanced > Network, click...

Powered by WHMCompleteSolution