in the applets in the project , always meet java.security.AccessControlException: this type of exception .
to summarize here applets situations and workarounds that are encountered with these anomalies .
A cause
This exception is caused by the security of Java .
applets code that belongs to the page load,so the security level is limited.,Which means,a lot of things,not granted by some specific permission,they can't do it..The following are prohibited operations:
Cannot access local file Span style= "font-family: Arial" > cannot read or write to Shenzhen cannot get information about files ( is there a , Modified date )
Cannot access any memory address
Cannot print document
other programs that cannot start the client , Which means no execution . system.exec () or runtime.exec ()
cannot get system parameters , System.getproperty (), It's even more impossible to set the system properties.
cannot define or use classloader,securitymanager,content-handlerfactory,socketimplfactory or urlstreamhandlerfactory a new instance of , must be an already existing instance .
cannot build except to load this applets links outside the host , That is, you can only load this applets the host
While these restrictions are somewhat relaxing for digitally signed code, sometimes
Two Fruits
the solution is that you add all of these operations to a privileged class , indicating that these operations are privileged .
Accesscontroller.doprivileged (New Privilegedaction () {public Object run () { //Privileged code goes here, for ex Ample: system.getproperty (...) returnnull;//nothing to return } );
The cause and effect of accesscontrolexception