One of the examples in "Java and mode" uses system. getproperty (string key)
System.getProperty("user.dir");
It's strange how he knows that the key is "user. dir ". Baidu has been sticking these keys for a long time. But where to find it? It took only half a day to find it:
In javase API, The getproperties method in the system class has the following descriptions:
Getproperties
public static Properties getProperties()
-
Determine the current system attribute.
First, if there is a security manager, directly call it without ParameterscheckPropertiesAccess
Method. This may cause a security exception.
SetgetProperty(String)
The current system property set used by the methodProperties
Object. If the current system property set does not exist, a system property set is created and initialized first. This system property set always contains the following key values:
Key |
Description of related values |
java.version |
Java Runtime Environment version |
java.vendor |
Java Runtime Environment vendor |
java.vendor.url |
Java vendor URL |
java.home |
Java installation directory |
java.vm.specification.version |
Java Virtual Machine standard version |
java.vm.specification.vendor |
Java virtual machine specification vendor |
java.vm.specification.name |
Java virtual machine specification name |
java.vm.version |
Java Virtual Machine implementation version |
java.vm.vendor |
Java Virtual Machine implementation vendor |
java.vm.name |
Java Virtual Machine implementation name |
java.specification.version |
Java Runtime Environment Standard version |
java.specification.vendor |
Java Runtime Environment specification vendor |
java.specification.name |
Java Runtime Environment specification name |
java.class.version |
Java format version number |
java.class.path |
Java class path |
java.library.path |
List of search paths when the library is loaded |
java.io.tmpdir |
Default temporary file path |
java.compiler |
Name of the JIT compiler to be used |
java.ext.dirs |
Path of one or more extended Directories |
os.name |
Operating system name |
os.arch |
Operating System Architecture |
os.version |
Operating system version |
file.separator |
File separator ("/" in UNIX) |
path.separator |
Path separator (":" in UNIX) |
line.separator |
Line separator ("/n" in UNIX ") |
user.name |
User Account Name |
user.home |
User's home directory |
user.dir |
Current working directory of the user |
Multiple paths in the system property values are separated by path delimiters of the platform.
Note that even if the security manager does not allow executiongetProperties
Operation, which may also allow execution
getProperty(String)
Operation.
-
-
Return Value:
-
System attributes
-
Throw:
-
SecurityException
-If the security manager exists and its
checkPropertiesAccess
The method does not allow access to system properties.
-
For more information, see:
-
setProperties(java.util.Properties)
,
SecurityException
,
SecurityManager.checkPropertiesAccess()
,
Properties