JAVA命令引數詳解:-D
阿新 • • 發佈:2019-02-10
原文地址:http://blog.sina.com.cn/s/blog_605f5b4f0100hlt9.html
JAVA 命令引數詳解:
1、-D<name>=<value> set a system property 設定系統屬性。
java命令引入jar時可以-cp引數,但是-cp不能用萬用字元(多個jar時什麼反要一個個寫,不能*.jar),通常的jar都在同一目錄,且多於1個。前些日子找到-Djava.ext.dirs太好。
如:
java -Djava.ext.dirs=lib MyClass
可以在執行前配置一些屬性,比如路徑什麼的。
java -D
這樣在Abc中就可以通過System.getProperty("config");獲得這個值了。
在虛擬機器的系統屬性中設定屬性名/值對,執行在此虛擬機器之上的應用程式可用。當虛擬機器報告類找不到或類衝突時可用此引數來診斷來檢視虛擬機器從裝入類的情況。
另外,javac -d <目錄> 指定存放生成的類檔案的位置
Standard System Properties
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 vender 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 |
所謂的 system porperty,system 指的是
JRE (runtime)system,不是指 OS。
System.setProperty("net.jxta.tls.principal", "client");
System.setProperty("net.jxta.tls.password", "password");
System.setProperty("JXTA_HOME",System.getProperty("JXTA_HOME","client"));
可以利用系統屬性來載入多個驅動