Java Class.getProtectionDomain()

Syntax

Class.getProtectionDomain() has the following syntax.

public ProtectionDomain getProtectionDomain()

Example

In the following code shows how to use Class.getProtectionDomain() method.


import java.security.ProtectionDomain;
//w  w  w  .  ja v  a2s  . com
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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable