Hi,
does anybody know what permissions I have to set to load a class using
the URLCLassLoader? The following code works without security manager
String path = "file:///home/user/dir_of_class/";
URLClassLoader loader = URLClassLoader.newInstance
(new URL[] { new URL(path) });
Class c = loader.loadClass("A");
but when I set a security manager it does not. I have already set the policy
grant codebase "file:///home/user/dir_of_loader_app/"
{
permission java.io.FilePermission
"file:///home/user/dir_of_class/-","read";
permission java.lang.RuntimePermission "*"
};
Unfortunately, the class loader just throws a ClassNotFoundException
instead of a SecurityException, so I can't figure out what is missing.
Or do I really have to set AllPermission?
Regards
JK.
JK - 12 Feb 2004 15:54 GMT
OK,I found it myself. I shouldn't set an URL in the FilePermission, so
permission java.io.FilePermission
"file:///home/user/dir_of_class/-","read";"file:///..."
should be
permission java.io.FilePermission
"/home/user/dir_of_class/-","read";"file:///..."
JK
> Hi,
>
[quoted text clipped - 22 lines]
> Regards
> JK.