2015-09-15 30 views
0

當我打電話給方法System.getProperties();並打印它們時,它給出了一個帶有鍵值對但沒有設置屬性的大列表 。 Java哪裏得到 那些屬性?System.getProperties的屬性來自哪裏?

+0

從Java虛擬機的實現中硬編碼值的底層計算機的性能和組合初始化自己的'Properties'對象。 [本新聞組帖子](https://groups.google.com/forum/#!topic/comp.lang.java.help/-JBBUicGRH4)涵蓋了相同的問題。 –

回答

3

來自託管Java的操作系統(環境)。檢查Oracle documentation

在屬性中,我們檢查了應用程序可以使用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