0

So I have this applet which loads images from a directory but it looks like Java is giving me some permission issues. I am a newbie when it comes to making applets on the web and tried to find solutions but most involve either command prompt or terminal access to the server hosting to the page. I don't have access to that. (Running on GoDaddy shared hosting)

java.lang.reflect.InvocationTargetException
    at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(DeployAWTUtil.java:116)
    at sun.plugin2.applet.Plugin2Manager.runOnEDT(Plugin2Manager.java:3541)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3072)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission ./setup/USPresidentialSeal.png read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
    at java.io.File.canRead(File.java:689)
    at javax.imageio.ImageIO.read(ImageIO.java:1274)

I have a PNG image located at

setup/USPresidentialSeal.png

Any help would be appreciated. (Also I am getting this error while running the applet from a HTML file located on my desktop.

  • *"I don't have access to that."* Do you have access to upload the class or Jar files? *"Any help would be appreciated"* Any question would be useful. Do you have one? – Andrew Thompson Apr 22 '12 at 18:21

1 Answers1

2

By default, applets do not have access to your local file system.

How can an applet Read/Write files on the local file-system?

Community
  • 1
  • 1
Travis Webb
  • 14,688
  • 7
  • 55
  • 109
  • It seems like signing applets would be the solution but I am a little confused. It looks that that would allow me to get access to the file system on the clients computer. I am trying to get access to the files on the same server that the applet is running on. For example, I am running the applet at example.com/index.html and the pictures are located at example.com/setup/USPresidentialSeal.png – Christian Turkoanje Apr 22 '12 at 18:37
  • Applets are executed on the client, not the server, so you have a fundamental misunderstanding of your own code. Applets can only directly access client resources. If you are trying to access server resources, you need to make the necessary requests to retrieve those resources. – Travis Webb Apr 22 '12 at 18:41
  • Ahh, I got it. I was trying to convert a Application to an Applet. Thanks for your help. – Christian Turkoanje Apr 22 '12 at 18:44