3

Below code :

URL oracle = new URL("http://www.oracle.com/");   
URLConnection inputStream =oracle.openConnection();
InputStream in = inputStream.getInputStream();

Throws this exception :

java.net.UnknownHostException: www.oracle.com
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:395)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:234)
        at sun.net.www.http.HttpClient.New(HttpClient.java:307)
        at sun.net.www.http.HttpClient.New(HttpClient.java:324)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)

I think this exception is thrown because the proxy server is blocking my connection? I just want to parse some data from the URL, can I accomplish this without running into the firewall ?

5
  • Can you access oracle.com in your browser? Commented Mar 28, 2012 at 14:11
  • 1
    If you could evade a firewall that easily, there wouldn't really be a point to it. If you think it's your firewall, is turning it off for a second an option? Commented Mar 28, 2012 at 14:12
  • Yes, www.oracle.com is accessible from my browser Commented Mar 28, 2012 at 14:12
  • Accessing the url in a browser is a good check too but would only mean something if that browser isn't using the proxy he mentioned. Commented Mar 28, 2012 at 14:13
  • I don't have the permissions to turn it off, even temporarily. Commented Mar 28, 2012 at 14:14

2 Answers 2

3

If you are using a proxy server, please make sure that you are setting the appropriate system properties. See the Oracle page at http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html for details.

Sign up to request clarification or add additional context in comments.

Comments

3

Make sure to include the below line in your manifest. It should be a direct child of manifest node.

<uses-permission android:name="android.permission.INTERNET" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.