如何授予 jar 文件执行另一个 jar 文件的权限
我想使用我的项目中的策略文件来执行 jar 文件。我的策略文件是:
*grant codeBase "file:///D:/xx/yy/zz/-"{
permission java.io.FilePermission
"D:/aa/bb/test.jar", "read, write, delete, execute";
};*
我的项目位于 D:/xx/yy/zz/ 文件夹下,我想在该项目中执行 test.jar 但出现错误:
访问被拒绝(java.io.FilePermission <> 执行)
如果我像这样更改策略文件,那没关系:
*grant codeBase "file:///D:/xx/yy/zz/-"{
permission java.io.FilePermission
"<<ALL FILES>>", "read, write, delete, execute";
};*
但我不想向我的项目授予所有权限。
而且在项目中我设置了这样的策略文件:
String path="D:\aa\bb\test.jar";
System.setProperty("java.security.policy","C:\\policy\\"+"test.policy");
System.setSecurityManager(new SecurityManager());
对于这种情况,有谁可以说一下吗? 谢谢...
I want to execute a jar file with using policy file from my project. my policy file is:
*grant codeBase "file:///D:/xx/yy/zz/-"{
permission java.io.FilePermission
"D:/aa/bb/test.jar", "read, write, delete, execute";
};*
my project is under D:/xx/yy/zz/ folder and i want to execute test.jar in this project but i had an error:
access denied (java.io.FilePermission <> execute)
if i change policy file like this, that is ok:
*grant codeBase "file:///D:/xx/yy/zz/-"{
permission java.io.FilePermission
"<<ALL FILES>>", "read, write, delete, execute";
};*
But i do not want to give all permission to my project.
And also in project i set policy file like this:
String path="D:\aa\bb\test.jar";
System.setProperty("java.security.policy","C:\\policy\\"+"test.policy");
System.setSecurityManager(new SecurityManager());
Is there any body to say something about this situation ?
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这个
"D:/aa/bb/test.jar"
应该是"D:\\aa\\bb\\test.jar"
在此处查看更多信息信息 http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html
I think this
"D:/aa/bb/test.jar"
should be"D:\\aa\\bb\\test.jar"
Check here for more info http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html
它看起来更像是文件系统安全问题而不是 java 安全异常,您使用的是 windows 还是 linux?
您使用什么类型的文件系统? ext2/3/4 或 NFTS 或 fat32 ?
最重要的是,您是否以管理员权限运行程序,这可能需要授予某些文件的执行权限。
It'looks a way more like a file system security problem than a java security exception, are you using windows or linux?
What kind of file system are you using ? ext2/3/4 or NFTS or fat32 ?
And most important, are you running your program with admin right, which might be necessary to grant execute permission on some files.