Use SecurityManager to check AWT permission and file permission : SecurityManager « Security « Java Tutorial

import java.awt.AWTPermission;

public class MainClass {
  public static void main(String args[]) throws Exception {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      FilePermission fp = new FilePermission("c:\\autoexec.bat", "read");

    if (sm != null) {
      AWTPermission ap = new AWTPermission("accessClipboard");
    System.out.println("Has AWTPermission to access AWT Clipboard");


36.41.1.extends SecurityManager
36.41.2.Use SecurityManager to check AWT permission and file permission
36.41.3.Listing All Permissions Granted to Classes Loaded from a URL or Directory
36.41.4.Define your own security manager
36.41.5.Enabling the Security Manager
36.41.6.To specify an additional policy file, set the system property at the command line:
36.41.7.To ignore the policies in the file, and use the specified policy, use '==' instead of '='