Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image not loading

 
Shalini Chandel
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i create an applet with a label attached to it. I load an image in a label:



Now when I load html file directly, applet is working perfectly fine.
i.e. d:\NewTest.html

but when i use server to display applet its giving security exception error..

http://localhost:8080/NewTest.html

How can we display image?
 
Norm Radder
Ranch Hand
Posts: 882
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does the ImageIcon() constructor try to read the image file from?
Is it from the server? That should be no problem!
Or is it from the local system? That will give you a Security exception.

Read the doc for the ImageIcon constructors and find one that will work when the image needs to come from the server. This many involve other classes such as URL.

When you get an error, please POST the FULL text of the message, don't edit it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic