I'd like to run java *.class files with restricted access (no network,
read anything, but write only in the current directory). `java -h`
does not appear to mention any relevant access restriction options, so
how can this be done (simply, and without having to take a Java
course)?
(I am not a Java programmer, so perhaps I shouldn't post in this
forum, but the other groups in comp.lang.java.* appear to be dead)
Tom Hawtin - 07 May 2007 18:45 GMT
> I'd like to run java *.class files with restricted access (no network,
> read anything, but write only in the current directory). `java -h`
> does not appear to mention any relevant access restriction options, so
> how can this be done (simply, and without having to take a Java
> course)?
You need to run the java command with a security manager and policy set
on the command line. Something like:
java -Djava.security.manager -Djava.security.policy=someURL SomeApp
You need to create a policy file with the permissions you want to give
the application.
Command line and policy syntax:
http://java.sun.com/javase/6/docs/technotes/guides/security/PolicyFiles.html
Details of permissions:
http://java.sun.com/javase/6/docs/technotes/guides/security/permissions.html
Obviously you don't want to give your application write permission on
your policy file.
Tom Hawtin