java.security.AccessControlException: Occured when Running an applet

后端 未结 1 955
夕颜
夕颜 2021-01-24 20:57

I am Learning Java Step by Step From Herbert Schildt Book Java2 Complete Reference Fifth Edition. On my way to creating simple Banner Applet which Display\'s Banner and Scrolls

相关标签:
1条回答
  • 2021-01-24 21:01

    Applets, by default, run in a sandbox environment with restricted permissions because of security reasons. Applets do not have runtime permissions to create or modify thread groups and hence you are getting the exception. Do not create a new thread group. Or else override your security policy to explicitly allow your applet to create one by granting the runtime permission to create or modify thread group. To override default permissions define appropriate policy in your user home's .java.policy file. It is recommended that you edit your user specific policy file and not the global policy file under your JRE security directory.

    Use a JDK's policy tool to define the policy or do it manually. Refer the template below:

    grant codeBase "<code base>" {
      permission <type> "<target>", "<actions>";
      permission <type> "<target>", "<actions>";
      ...
    };
    
    For eg. 
    grant codeBase "http://geosim.cs.vt.edu/geosim/-" {
      permission java.lang.RuntimePermission "modifyThreadGroup";
      ...
    };
    
    0 讨论(0)
提交回复
热议问题