Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Image Import Permissions

3 views
Skip to first unread message

Cyber Dog

unread,
May 21, 2001, 5:07:52 PM5/21/01
to
I'm writing/compiling a somewhat complex Java Applet on a pc running Windows
ME with JDK 1.3.1. I'm trying to import a GIF image into the applet. The
gif is located in the same directory as the applet, but when the applet
executes on my machine I get the following permissions error:

java.security.AccessControlException: access denied (java.io.FilePermission
\C:\
Program Files\Metrowerks\My Projects\Java\waterballoon_1\target0.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at
java.security.AccessController.checkPermission(AccessController.java:
399)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkRead(SecurityManager.java:890)
at sun.awt.image.URLImageSource.<init>(URLImageSource.java:40)
at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:36)
at sun.misc.Ref.get(Ref.java:49)
at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:341)
at sun.applet.AppletViewer.getImage(AppletViewer.java:336)
at java.applet.Applet.getImage(Applet.java:196)
at java.applet.Applet.getImage(Applet.java:218)
at menu.init(menu.java)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)

I know (or at least I've been lead to believe) that this is because the Java
Plug-in does not have permissions to read files off of my hard drive. How
can I work around these permissions for my program so I can continue my
programming? Thanks.


nille40

unread,
May 21, 2001, 5:05:57 PM5/21/01
to
Do you use the Toolkit.getDefaultToolkit().getImage() method?
Don't! Since that method is for importing images from a
harddrive (not a URL) it will cast a Security Exception. Applets
don't have access to the user's harddrive. Use the getImage
method found in Applet instead. Or you could sign your applet by
letting some organization review the code in your applet. This
is a time consuming task, so I would go with the getImage() in
Applet. As it seems, you need to store the getCodeBase() URL in
a URL object upon init() (you'll need that in getImage()).
Otherwise you will get an exception. Don't know why...

Nille

VisionSet

unread,
May 21, 2001, 5:54:52 PM5/21/01
to
mmmmmmmmmm
I have my images all jarred up and the following method is called from
init()
In I.E. everything works fine but netscape can't find the images, is this a
connected issue?

mike

public void getImages() {

MediaTracker mt = new MediaTracker(this);

tile = new Image[27];
for(int i=0;i<27;i++) {
String temp = ((char)(i+65)+".gif");
tile[i] = getImage(getDocumentBase(),temp);
mt.addImage(tile[i], i);
}
board = getImage(getDocumentBase(),"Board.gif");
mt.addImage(board, 27);
hilite = getImage(getDocumentBase(),"Pick.gif");
mt.addImage(hilite, 28);

try {mt.waitForAll();}
catch (Exception e) {System.err.println("media tracker interrupted");}
}

"nille40" <nille40...@sun.partner.remarq.com.invalid> wrote in message
news:00000030...@usw-ex0107-167.remarq.com...

0 new messages