Class.getProtectionDomain() has the following syntax.
public ProtectionDomain getProtectionDomain()
In the following code shows how to use Class.getProtectionDomain() method.
import java.security.ProtectionDomain; /* ww w . ja v a 2 s . c o m*/ public class Main { public static void main(String[] args) throws Exception { Class cls = Class.forName("Main"); // returns the name of the class System.out.println("Class = " + cls.getName()); // returns the ProtectionDomain of this class. ProtectionDomain p = cls.getProtectionDomain(); System.out.println(p); } }
The code above generates the following result.