System.getProperties的属性来自哪里?

时间:2015-09-15 13:46:20

标签: java properties

当我调用方法System.getProperties();并打印出来时,它给出了 一个没有设置属性的键值对的大列表。 Java在哪里获得 那些属性来自?

1 个答案:

答案 0 :(得分:3)

来自托管Java的操作系统(环境)。查看Oracle documentation

  

在Properties中,我们检查了应用程序使用Properties对象维护其配置的方式。 Java平台本身使用Properties对象来维护自己的配置。 System类维护一个Properties对象,该对象描述当前工作环境的配置。系统属性包括有关当前用户,Java运行时的当前版本以及用于分隔文件路径名的组件的字符的信息。

Key                 Meaning
-----------------   --------------------------------------------------------------------------
"file.separator"    Character that separates components of a file path. This is "/" on UNIX and "\" on Windows.
"java.class.path"   Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property.
"java.home"         Installation directory for Java Runtime Environment (JRE)
"java.vendor"       JRE vendor name
"java.vendor.url"   JRE vendor URL
"java.version"      JRE version number
"line.separator"    Sequence used by operating system to separate lines in text files
"os.arch"           Operating system architecture
"os.name"           Operating system name
"os.version"        Operating system version
"path.separator"    Path separator character used in java.class.path
"user.dir"          User working directory
"user.home"         User home directory
"user.name"         User account name