i added a menu bar in applet .in this menu there is option "open".
when we click on this Filedialog should open but it is not happening.
some security exception is thrown.
can i change the permission through coding in applet file?
if yes, give me idea of that
> i added a menu bar in applet .in this menu there is option "open".
> when we click on this Filedialog should open but it is not
> happening. some security exception is thrown.
> can i change the permission through coding in applet file?
> if yes, give me idea of that
Hi,
An applet isn't allowed to access files on your local hard drive, for
security reasons; I'm assuming this same idea applies to opening file
dialogs. There are two ways around this:
1. If this applet is being used on computers under your control
(corporate LAN, etc), you can find the appropriate policy file for
the Java plugin (I think it's called "java.policy" and can be found
in your JRE/lib/security directory), and add the following lines:
grant codeBase "http://www.example.com/mydirectory/*" {
java.io.FilePermission "<<ALL FILES>>", "read";
};
If you want the code to be able to write to files as well as read,
change "read" to "read,write". For deletion as well,
"read,write,delete". See the javadocs for FilePermission for all the
details. Note that these lines have to be added on ALL the machines
on your LAN that need the applet to work. Also, if any machine is
using Internet Explorer without the Java plugin, I have no idea where
the policy file is (or even if it exists).
2. If this applet is being used on computers not under your control,
the only option is to sign the code. I've never done it, so I don't
know what happens, but, basically, you'll need to sign at least twice
(I think): once for the Java plugin, and once for Internet Explorer
users not using the plugin. To sign code requires a certificate which
you can obtain (at cost) from a certification authority like
Verisign. Once it's signed, I'm not sure exactly where you go from
there.
Chris