You will need to use the security manager; see the Security Features in Java SE tutorial to start with. This is how applets are prevented from accessing local files, and from using reflection to get around these limits.