All Collections
How to Use Guides
Script
How to use HTTP Proxies in Java code using Limeproxies?
How to use HTTP Proxies in Java code using Limeproxies?
Steve M avatar
Written by Steve M
Updated over a week ago

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?