To continue further development with Java, make sure to read their documentation.
To run the following code example, you'll need Java, the Java SE Runtime Environment (JRE) and an IDE set up on your machine:
You should also have a Smartproxy account with access to the dashboard to get your credentials and endpoint information.
This particular code was built using Eclipse.
If you choose to run the code using a different method or want to execute the script with the javac
command, you may need to install the Server JRE.
- Create a project folder by running the following command in your Terminal tool:
mkdir java_example
- Navigate to the main directory of your project folder using
cd java_example
. - Copy the code directly from here, or execute the following command to download the proxy setup example file:
curl https://raw.githubusercontent.com/Smartproxy/Smartproxy/master/java/java.java > java.java
- You should see a new file named
java.java
in your project folder. Open it using an editor of your choice.
To run this Java example, set your username, password, and endpoint information you'd like to use and enter them in the following sections of the code:
You should see an IP address in the console window if everything was set up correctly:
Note: If you're targeting HTTPS, the Basic Authentication scheme in some setups may not work (error: "HTTP/1.1 407 Proxy Authentication Required"). You can solve this issue by proxying HTTP, changing the authentication scheme of the proxy to Digest Authentication, or disabling Basic Authentication for HTTPS tunneling by setting the system property to "" (blank) when running the code:
java -Djdk.http.auth.tunneling.disabledSchemes="" java.java
Email - sales@smartproxy.com