error:access denied (java.security.SecurityPermission getPolicy)

Hi,

I want set some permission from within my code as following:

Policy isgPolicy;

try{

isgPolicy=Policy.getPolicy();

PermissionCollection isgPC=isgPolicy.getPermissions(new CodeSource(codeBase,null));

isgPC.add(new FilePermission("java.lang.RuntimePermission","writeFileDescriptor"));

}catch(Exception e){};

But the Policy.getPolicy() method will throw java.security.SecurityPermission "access denied" exception. I have no idea what to do at all. Please help.

Thank you.

Janet

[561 byte] By [kfsong] at [2007-9-26 4:08:45]
# 1
Actually you can't use Policy class directly though it exists. The way to modify policy is to use policy tool in the jdk/bin/ directory.in the command line, type in policytool and it will bring up a window for you to edit the policy and then you have to save the file.
Ilikejava at 2007-6-29 13:11:12 > top of Java-index,Archived Forums,Java Programming...
# 2
Thank you for your reply.I know about the tool, but the problem is that I cannot let my clients to modify the policy file themselves, so I want to set it within my code. And from some posts in this forum, it seems it is possible to set the policy from within the pragram.
kfsong at 2007-6-29 13:11:12 > top of Java-index,Archived Forums,Java Programming...