Help figure out why my applet won't run on my Mac.
May 19, 2008 10:27 PM Subscribe
Why would an applet work fine on my school's Windows computers, only to throw "java.security.AccessControlException: access denied (java.io.FilePermission filename.gif read)" when I attempt to run it on my Mac? This is using a lot of Java stuff I'm quite unfamiliar with, so be prepared to talk down to me. The thing-I-don't-understand in question is mostly something called MediaTracker, if that rings any bells. Many more details inside and upon request.
So, I'm working on a CS project (I'm in my second year of HS computer science) that basically involves creating our own game. Fun little end of semester project, except we're running short on time (AP/IB exams for me and my partner got in the way). Our teacher provided us with a base framework for dealing with applets and images and threads and such which makes things look nicer, but which are nothing we're familiar with. I can *use* all this unknown stuff, but fixing it is beyond me. Currently, our program (such as it is) runs fine on the computers at school, using whatever applet viewer JCreator uses (I assume nothing special?) When I try to open the HTML file with the applet at home in Firefox, I get the error message I wrote out before. Same thing happens in Safari. The problem (based on the Java console I found in the Firefox Web Developer extension) is on this line:
myImage = Toolkit.getDefaultToolkit().getImage("filename.gif");
I am happy to look for and copy out anything else, including the full error console readout, but I am hesitant to just put the whole dang thing up because frankly I would imagine it's overkill. The main thing is it works fine a school; I just can't figure out what's wrong with it at home. Incidentally, the reason I want it to work on my laptop so bad is so I can work on it more easily outside of class. I'll probably go kick my brother off our home Windows desktop (and will report back if that solves/doesn't solve the problem), but for the future mobility => maximized workin' time. So thank you a thousand times if you can figure this out for me, as googling has simply made me more aware of how far above my head I am working.
posted by MadamM to computers & internet (7 answers total)
Just a guess, but what's happening might be that the Java applet is trying to open the file "filename.gif", which it is searching for in your current working directory - that is, the directory that Firefox is running in, not the directory that your source code is in.
Try providing the full (Unix) path to "filename.gif", if you know it. (If you don't know what I'm talking about, try reading through this tutorial ). If your image is in a directory named "src" in your homedir, the path would be /Users/yourusername/src/filename.gif .
If that still doesn't work, it may be a permissions problem. Navigate to the directory using Terminal.app, then enter the command "chmod a+r filename.gif" and try again. (This command sets the Unix "read" permission bit for all users - it allows everyone to read that file).
posted by ArbiterOne at 10:43 PM on May 19, 2008