java的System.getProperty()可以擷取的值

來源:互聯網
上載者:User

標籤:

最近在看代碼的時候看見了System.getProperty("user.dir")這個方法,覺得有必要記一下,就將所有與System.getproperty(),有關的參數這裡了一下,下面是這些參數的一些解釋:

一:System.getproperty()可以傳遞的參數

(1)java.vendor    Java 運行時環境供應商
(2)java.vendor.url    Java 供應商的 URL
(3)java.home    Java 安裝目錄
(4)java.vm.specification.version    JAVA 虛擬機器規範版本
(5)java.vm.specification.vendor    JAVA 虛擬機器規範供應商
(6)java.vm.specification.name    JAVA 虛擬機器正式名稱
(7)java.vm.version    JAVA 虛擬機器實現版本
(8)java.vm.vendor    JAVA 虛擬機器實現供應商
(9)java.vm.name    JAVA 虛擬機器實現名稱
(10)java.specification.version    Java 運行時環境規範版本
(11)java.specification.vendor    Java 運行時環境規範供應商
(12)java.specification.name    Java 運行時環境正式名稱
(13)java.class.version    Java 類格式版本號碼
(14)java.class.path    Java 類路徑
(15)java.library.path    載入庫時搜尋的路徑列表
(16)java.io.tmpdir    預設的臨時檔案路徑
(17)java.compiler    要使用的 JIT 編譯器的名稱
(18)java.ext.dirs    一個或多個擴充目錄的路徑
(19)os.name    作業系統的名稱
(20)os.arch    作業系統的架構
(21)os.version    作業系統的版本
(22)file.separator    檔案分隔字元(在 UNIX 系統中是“/”)
(23)path.separator    路徑分隔字元(在 UNIX 系統中是“:”)
(24)line.separator    行分隔字元(在 UNIX 系統中是“/n”)
(25)user.name    使用者的賬戶名稱
(26)user.home    使用者的主目錄
(27)user.dir    使用者的當前工作目錄

 

二:參數實際調用及輸出的結果

@Test
 public void testSystemGetProperty(){
        System.out.println("java.version-->"+System.getProperty("java.version"));
        System.out.println("java.vendor-->"+System.getProperty("java.vendor"));
        System.out.println("java.vendor.url-->"+System.getProperty("java.vendor.url"));
        System.out.println("java.home-->"+System.getProperty("java.home"));
        System.out.println("ava.vm.specification.versionr-->"+System.getProperty("ava.vm.specification.version"));
        System.out.println("java.vm.specification.vendor-->"+System.getProperty("java.vm.specification.vendor"));
        System.out.println("java.vm.specification.name-->"+System.getProperty("java.vm.specification.name"));
        System.out.println("java.vm.version-->"+System.getProperty("java.vm.version"));
        System.out.println("java.vm.vendor-->"+System.getProperty("java.vm.vendor"));
        System.out.println("java.vm.name-->"+System.getProperty("java.vm.name"));
        System.out.println("java.specification.version-->"+System.getProperty("java.specification.version"));
        System.out.println("java.specification.vendor-->"+System.getProperty("java.specification.vendor"));
        System.out.println("java.specification.name-->"+System.getProperty("java.specification.namer"));
        System.out.println("java.class.version-->"+System.getProperty("java.class.version"));
        System.out.println("java.class.path-->"+System.getProperty("java.class.path"));
        System.out.println("java.library.path-->"+System.getProperty("java.library.path"));
        System.out.println("java.io.tmpdir-->"+System.getProperty("java.io.tmpdir"));
        System.out.println("java.compiler-->"+System.getProperty("java.compiler"));
        System.out.println("java.ext.dirs-->"+System.getProperty("java.ext.dirs"));
        System.out.println("os.name-->"+System.getProperty("os.name"));
        System.out.println("os.arch-->"+System.getProperty("os.arch"));
        System.out.println("os.version-->"+System.getProperty("os.version"));
        System.out.println("file.separator-->"+System.getProperty("file.separator"));
        System.out.println("path.separator-->"+System.getProperty("path.separator"));
        System.out.println("line.separator-->"+System.getProperty("line.separator"));
        System.out.println("user.name-->"+System.getProperty("user.name"));
        System.out.println("user.home-->"+System.getProperty("user.home"));
        System.out.println("user.dir-->"+System.getProperty("user.dir"));
}

-------------------------一下是輸出結果-----------------------------

java.version-->1.7.0_79
java.vendor-->Oracle Corporation
java.vendor.url-->http://java.oracle.com/
java.home-->D:\kassdev\jdk1.7\jre
ava.vm.specification.versionr-->null
java.vm.specification.vendor-->Oracle Corporation
java.vm.specification.name-->Java Virtual Machine Specification
java.vm.version-->24.79-b02
java.vm.vendor-->Oracle Corporation
java.vm.name-->Java HotSpot(TM) Client VM
java.specification.version-->1.7
java.specification.vendor-->Oracle Corporation
java.specification.name-->null
java.class.version-->51.0
java.class.path-->D:\workspace\myeclipse\webTest01\WebRoot\WEB-INF\classes;D:\software\myeclipse\Common\plugins\org.junit4_4.5.0.v20090824\junit.jar;D:\software\myeclipse\Common\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;/D:/software/myeclipse/MyEclipse 8.5/configuration/org.eclipse.osgi/bundles/642/1/.cp/;/D:/software/myeclipse/MyEclipse 8.5/configuration/org.eclipse.osgi/bundles/640/1/.cp/;/D:/software/myeclipse/MyEclipse 8.5/configuration/org.eclipse.osgi/bundles/641/1/.cp/
java.library.path-->D:\kassdev\jdk1.7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:/software/myeclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;D:/software/myeclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\kassdev\kass\jdk1.7\bin;D:\devtools\TortoiseSVN\bin;D:\soft\UltraEdit;D:\soft\nodejs\;D:\software\apache-ant-1.9.6\bin;D:\software\python;D:\kassdev\kass\jdk1.7\jre\bin;D:\kassdev\jdk1.7\bin;D:\software\SSH;C:\Users\Tom\AppData\Roaming\npm;.
java.io.tmpdir-->C:\Users\Tom\AppData\Local\Temp\
java.compiler-->null
java.ext.dirs-->D:\kassdev\jdk1.7\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
os.name-->Windows 8.1
os.arch-->x86
os.version-->6.3
file.separator-->\
path.separator-->;
line.separator-->

user.name-->Tom
user.home-->C:\Users\Tom
user.dir-->D:\workspace\myeclipse\webTest01

總結:以上是關於System.getproperty()的一些總結,讀者可以將代碼copy後測試一下,看看自己電腦上的測試結果。

 

java的System.getProperty()可以擷取的值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.