The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
To grant the GetProps
application permission to read the "user.home"
and "java.home"
property values, you must create a policy entry granting those permissions. Choose the Add Policy Entry button in the main Policy Tool window. This brings up the Policy Entry dialog box, as shown in the following figure.
Type the following file URL into the CodeBase text box to indicate that you are going to be granting a permission to code from the specified directory, which is the directory in which GetProps.class
is stored.
file:/C:/Test/
(Note, this is a URL and thus must always have slashes, not backslashes.)
Leave the SignedBy text box blank, since you aren't requiring the code to be signed.
To add permission to read the "user.home"
property value, choose the Add Permission button. This brings up the Permissions dialog box.
Do the following.
java.util.PropertyPermission
) now appears in the text box to the right of the drop-down list."user.home"
property:
user.home
Now the Permissions dialog box looks like the following.
Choose the OK button. The new permission appears in a line in the policy entry window.
To add permission to read the "java.home"
property value, choose the Add Permission button again. In the Permissions dialog box, do the following:
"java.home"
property:
java.home
Now the Permissions dialog box looks like the following.
Choose the OK button. The new permission and the previously added permission appear in lines in the policy entry window, as shown in the following figure.
You are now done specifying this policy entry, so choose the Done button in the Policy Entry dialog. The Policy Tool window now includes a line representing the new policy entry, showing the CodeBase value.