Hi, I have an
applet, it worked fine, until, I decided to look at the local filesystem from inside the applet.
The exception comes from using File.list() method, used so that I can get the subdirectory names of the "images" directory, which resides in the same directory as applet on the server.
Here is the output from the Sun
Java Console verifying the File.list() as the place where it has an exception
Java Plug-in 1.6.0_01
Using JRE version 1.6.0_01 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Colin
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
IN CONSTRUCTOR
java.security.AccessControlException: access denied (java.io.FilePermission images read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.list(Unknown Source)
at foto.Directory.setEndDirectory(Directory.java:75)
at foto.Directory.<init>(Directory.java:25)
at foto.Main.start(Main.java:57)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Since all I need to do is read names of directories I thought it might be possible to not use a signed applet, and just use a Policy File thing.
I read Javaranch's FAQ, and it says I can use...
So for the codeBase, I replaced it with
"http://www.colin-java.co.uk/FotoCube"
This is the directory where the JAR file and HTML page reside.
I'm using Eclipse, which creates a java.policy.applet file, similar to the code above, so I put the new code in, and exported it with the JAR.
But I'm still getting exactly the same exception when I run the applet in the browser.
Do I have the codeBase line correct, or is the java.policy.applet code wrong, or am I doing something else wrong?
Please can someone advise me so I can read names of subdirectories inside the applet.
Thanks for any help.