try out the java security guide,created the policy file,saved as a examplepolicy in local folder,the go to run the command line that invoke the applet view from sun.
appletviewer -J-Djava.security.policy=examplepolicy http://docs.oracle.com/javase/tutorial/security/tour1/examples/WriteFile.html
if we run the appletviewer from the folder that contains examplepolicy,the applet will be correctly run.oterwise the examplepolicy can not be find,so the applet will fail.
since the default jre\lib\security\java.security has a default item that load the policy from {user_home}\.java.policy,we can save newly created policy into that file,the invoke the applet anywhere,just make sure has the permission to write to that folder.
developers normally set up their JAVA_HOME to a JDK, so make sure change the java.security file in JDK\JRE\lib\security\java.security ,not the file under Program Files\Java\Jre\lib\security\java.security
No comments:
Post a Comment