Java Class getProtectionDomain() Method

The getProtectionDomain() method of java Class class returns the ProtectionDomain of this class. This method internally calls the checkPermission() method of the Security Manager (installed with this class) is called with a RuntimePermission to check if it is okay to get the protection domain.

Syntax

Parameter

NA

Returns

ProtectionDomain

Throws

SecurityException.

Example 1

Test it Now

Output:

Class = ClassgetProtectionDomainExample1
ProtectionDomain  (file:/C:/Users/Suman/Documents/NetBeansProjects/calendar/build/classes/ 
<no signer certificates>)
 sun.misc.Launcher$AppClassLoader@2a139a55
 <no principals>
 java.security.Permissions@4e25154f (
 ("java.io.FilePermission" "\C:\Users\Suman\Documents\NetBeansProjects\calendar\build\classes\-" "read")
 ("java.lang.RuntimePermission" "exitVM")
)

Example 2

Test it Now

Output:

ProtectionDomain  (file:/C:/Users/Suman/Documents/NetBeansProjects/calendar/build/classes/ 
<no signer certificates>)
 sun.misc.Launcher$AppClassLoader@2a139a55
 <no principals>
 java.security.Permissions@4e25154f (
 ("java.io.FilePermission" "\C:\Users\Suman\Documents\NetBeansProjects\calendar\build\classes\-" "read")
 ("java.lang.RuntimePermission" "exitVM")
)

Next TopicJava Class




Latest Courses