How to provide grant to jar file to execute another jar file

I want to execute a jar file using the policy file from my project. my policy file:

*grant codeBase "file:///D:/xx/yy/zz/-"{ permission java.io.FilePermission "D:/aa/bb/test.jar", "read, write, delete, execute"; };* 

my project is under the folder D: / xx / yy / zz /, and I want to run test.jar in this project, but I had an error:

access denied (java.io.FilePermission <> execute)

if I modify the policy file like this, this is normal:

 *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 permissions to my project.

And also in the project, I install the policy file as follows:

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...

+4
source share
2 answers

I think this is "D:/aa/bb/test.jar" should be "D:\\aa\\bb\\test.jar"

More details here http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html

+1
source

This looks more like a file system security issue than a Java security exception, are you using Windows or Linux?
What file system are you using? ext2 / 3/4 or NFTS or fat32?
And most importantly, you run your program with administrator rights, which may be required to provide permission to execute certain files.

0
source

Source: https://habr.com/ru/post/1394376/


All Articles