I have a Java applet that requires the use of some folders to read in some files and such. The folders are in the proper location and are sitting in the same directory as the index.html (which runs the applet). Here is the error that JApplet spits out:
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 ./results 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.list(File.java:971)
at java.io.File.listFiles(File.java:1129)
at WhoHasMore.JShellFrame.getDefaultResultsFileName(JShellFrame.java:453)
at WhoHasMore.JShellFrame.<init>(JShellFrame.java:28)
at WhoHasMore.<init>(WhoHasMore.java:23)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at sun.plugin2.applet.Plugin2Manager$13.run(Plugin2Manager.java:3060)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:638)
at java.awt.EventQueue$1.run(EventQueue.java:636)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception: java.lang.reflect.InvocationTargetException
As you can see, the error seems to be coming from
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission ./results read)
Why is the access denied to read from the folder called “results”? How do I fix this?
The method you’re trying to use (
java.io.File.listFiles) does not work over HTTP. You will need to choose another way of listing files, such as putting a list of files in a text file at a known URL and downloading that, or making it part of the applet jarfile.