一、文章的目的
這是一篇對(duì)Java安全管理器入門(mén)的文章,目的是簡(jiǎn)單了解什么是SecurityManager,對(duì)管理器進(jìn)行簡(jiǎn)單配置,解決簡(jiǎn)單問(wèn)題。
比如在閱讀源碼的時(shí)候,發(fā)現(xiàn)這樣的代碼,想了解是做什么的:
SecurityManager security = System.getSecurityManager();if (security != null) { security.checkWrite(name); }
亦或者在本機(jī)運(yùn)行正常,在服務(wù)器運(yùn)行報(bào)錯(cuò),想解決問(wèn)題:
Exception in thread "main" java.security.AccessControlException: access denied (java.lang.RuntimePermission createSecurityManager) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374) at java.security.AccessController.checkPermission(AccessController.java:549) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.<init>(SecurityManager.java:282) at xia.study._01Thread.ThreadTest.creatThread1(ThreadTest.java:18) at xia.study._0