Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default 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?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default 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)

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default 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
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default 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.

  5. #5
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default 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.

Similar Threads

  1. Displaying an Image!
    By javabeginner29 in forum Java Applets
    Replies: 3
    Last Post: 02-15-2012, 12:08 PM
  2. Image not displaying
    By sandeep43 in forum New To Java
    Replies: 20
    Last Post: 07-08-2011, 12:31 AM
  3. Displaying an image
    By Samari413 in forum New To Java
    Replies: 10
    Last Post: 11-06-2010, 08:56 PM
  4. Displaying an image
    By SWEngineer in forum AWT / Swing
    Replies: 11
    Last Post: 01-28-2010, 05:48 AM
  5. Displaying image in same jsp
    By SreenivasGurramkonda in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-08-2008, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •