Oliveira.caio
System.setProperty("https.proxyHost", "Servidor");
System.setProperty("https.proxyPort", "Porta");
//Caso tenha usuário e senha
System.setProperty("http.proxyUser", "myuser");
System.setProperty("http.proxyPassword", "mypassword");
paulofernandesjr
Não deu certo
será que pode ser o firewall do windows?
package test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class ConectaProxy {
public static void main(String[] args) throws Exception{
System.setProperty("https.proxyHost", "192.168.0.3");
System.setProperty("https.proxyPort", "3000");
System.setProperty("http.proxyUser", "teste");
System.setProperty("http.proxyPassword", "teste");
String url = "http://www.guj.com.br";
URL u = new URL(url);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
uc.connect();
InputStream i = uc.getInputStream();
InputStreamReader isr = new InputStreamReader(i);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
abraço
furutani
Vc só configurou para HTTPS, faltou para HTTP
# System.setProperty("http.proxyHost", "192.168.0.3");
# System.setProperty("http.proxyPort", "3000");
paulofernandesjr
agora dá esse erro, volto a perguntar, não pode ser nada com firewall do windows?
Oliveira.caio
Tenta Fazer Isso.
System.getProperties().put("http.proxyHost", "myHost");
System.getProperties().put("http.proxyPort", "8080");
System.getProperties().put("http.proxyUser", "myuser");
System.getProperties().put("http.proxyPassword", "mypass");
Authenticator.setDefault(new Authenticator(){
protected PasswordAuthentication setAuthentication() {
return new PasswordAuthentication("myUser", "myPass".toCharArray());
}
});
paulofernandesjr
Mesmo erro!
Ainda não funcionou
Oliveira.caio
Poste o codigo que você esta tentando.
Mais antes sete a seguinte propriedade;
System.setProperty("http.proxySet", "true");
Oliveira.caio
paulofernandesjr
Deu certinho com este ultimo link cara!
muito obrigado pelo help
abraço