隨筆-314  評論-209  文章-0  trackbacks-0

          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 -Dconfig="d:/config/config.xml" Abc

          這樣在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"));
          可以利用系統屬性來加載多個驅動

          posted on 2015-01-21 10:09 xzc 閱讀(883) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 武川县| 宜兰市| 北票市| 闽侯县| 赤壁市| 兴宁市| 梨树县| 山丹县| 新乡市| 林周县| 丽水市| 岳阳市| 福贡县| 麟游县| 岱山县| 普兰店市| 东乡县| 浦北县| 察哈| 渭南市| 锦屏县| 麻城市| 新建县| 绥棱县| 武山县| 柞水县| 安福县| 广昌县| 武威市| 咸宁市| 左云县| 云龙县| 漳平市| 南充市| 卢龙县| 建德市| 湛江市| 石阡县| 丰镇市| 滨州市| 泰和县|