JAVA 命令参数详解:-D

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"));
可以利用系统属性来加载多个驱动

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值