2

I have searched and looked and I cannot seem to find the source of my problem. I have code that is supposed to be taking a url, but for some reason no matter what I do. It seems to not be connected.

src = "http://ecx.images-amazon.com/images/I/410oAxun7dL._AA300_.jpg"
URL url = new URL(src);
URLConnection connection = (URLConnection) url.openConnection();
((HttpURLConnection) connection).setRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();

I get a java.net.SocketException: Permission denied error.

What is the cause of this error? And How would I fix it?

Thank you for your help!

2
  • 1
    Is that code in an Applet application? Commented Jun 23, 2011 at 19:57
  • Could you show the entire stack trace and tell us which line throws the exception? Also, as Marcelo mentions, if it's an Applet (or a Java Web Start app for that matter) that could affect it. Commented Jun 23, 2011 at 20:01

2 Answers 2

1

I'm assuming you are trying to do this code in an Applet. That is not allowed, you will have to digitally sign your applet to get it to be allowed to access another server.

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

Comments

0

Could be a permissions issue on the folder? Make sure you can browse to the image via the browser.

1 Comment

It's an image on Amazon, at least the one in his example is. I tried it and it worked, though it's an odd image.

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.