I am using below code to connect to a url. Iam getting this error while executing it in my office system. but on my personal laptop it is working. I think it has to do something with the proxy. i have the proxy details . but how to specify it in the below code??
java.net.UnknownHostException: www.google.com
import java.util.Properties;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.methods.GetMethod;
public class test {
public static void main(String args[]) throws Exception {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://www.google.com");
try{
client.executeMethod(method);
}catch(Exception e) {
System.err.println(e);
}finally {
method.releaseConnection();
}
}
}
From KodeJava
And then use your existing code to execute the method.