So when I try to load my applet from my website I get
AccessControlException
access denied ("java.io.FilePermission" "cursor.gif" "read")
This corresponds to the code inside my applet.
//Modify the cursor when inside the Applet
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursorIcon = toolkit.getImage("cursor.gif");
Point center = new Point(16, 16);
Cursor cursor = toolkit.createCustomCursor(cursorIcon, center, "Cursor");
setCursor(cursor);
I HAVE googled and tried things such as
.jar
My applet works perfectly fine when I run it in my eclipse Additionally, if I comment out the code above, my applet works, so just that portion is giving me an error.
You have to wrap your code inside privileged code like:
final String location = locationVal;
File f = (File) AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
System.out.println("Getting File : " + location);
File outputFile1 = new File(location);
return outputFile1;
}
});
This code is copied from: where policy file location for my applet that needs clients permission to access resource?
Also useful links:
http://docs.oracle.com/javase/6/docs/technotes/guides/security/PolicyFiles.html about java policy implementation.
http://docs.oracle.com/javase/1.3/docs/tooldocs/win32/policytool.html#Usage using GUI policy file editor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.