Skip to content

How to use HTTP Proxies in Java code using Limeproxies

Before using our proxies, ensure that your server IP address is authorized via the proxy control panel.The Code below is a sample code for using proxies in Java code: 

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

 

classProxyTest {
  public static void main(String[] args) throws Exception {
    InetSocketAddressproxyAddress = new InetSocketAddress("1.1.1.1", 1212); // Set proxy IP/port.
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
    URL url = new URL("http://checkip.limeproxies.com/");
    URLConnectionurlConnection = url.openConnection(proxy);
    Scanner scanner = new Scanner(urlConnection.getInputStream());
    System.out.println(scanner.next());
    scanner.close();
  }
}

Did this answer your question? If not, open a support ticket and a human will pick it up.