Error displaying an Image!
Im working on macosX
Following is my code:
import java.applet.*;
import java.awt.*;
public class PaintBanner2 extends Applet{
Image testImage;
public void init(){
testImage = getImage(getDocumentBase(),getParameter("testImage "));
}
public void paint(Graphics g){
g.drawImage(testImage, 0, 0, this);
}
}
my html file is :
<html>
<body>
<applet code="PaintBanner2.class" width=300 height=300>
<param NAME=testImage Value = "file:///Users/......./Desktop/IMG-20111217-00053.jpg">
</applet>
</body>
</html>
Im getting the following error when I tried to display the image...
appletviewer PaintBanner2.html
java.security.AccessControlException: access denied (java.io.FilePermission /Users/....../Desktop/IMG-20111217-00053.jpg read)
at java.security.AccessControlContext.checkPermission (AccessControlContext.java:323)
at java.security.AccessController.checkPermission(Acc essController.java:546)
at java.lang.SecurityManager.checkPermission(Security Manager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManage r.java:871)
at sun.awt.image.URLImageSource.<init>(URLImageSource .java:39)
at sun.applet.AppletImageRef.reconstitute(AppletImage Ref.java:33)
at sun.misc.Ref.get(Ref.java:47)
at sun.applet.AppletViewer.getCachedImage(AppletViewe r.java:377)
at sun.applet.AppletViewer.getImage(AppletViewer.java :372)
at java.applet.Applet.getImage(Applet.java:242)
at java.applet.Applet.getImage(Applet.java:264)
at PaintBanner2.init(PaintBanner2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:637)
What next??Can anyone please help?
Re: Error displaying an Image!
The AccessControlException is a sign you are trying to do something your applet is not allowed to do (eg load a file from the local file system). See What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Java Applets)
Re: Error displaying an Image!
So, you ask a new, related question without replying to my second response in your last thread? Don't you have any manners?
db
Re: Error displaying an Image!
Sorry db,, I replied.. due to some reason it didnt get posted..Anyway,, I got a new book... The Complete reference..so working on it.
Re: Error displaying an Image!
Got it folks.. sorry for the trouble..The gif or the jpeg file must be in the same directory as the html file.