JAVA -D命令选项

本文介绍了如何使用Java的-D选项来设置系统属性,并给出了具体的示例。此外还对比了-D选项与-d选项的区别,强调了大小写的重要性。文章列举了一些默认已设置的系统属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A JVM runs with a number of system properties. You can configure system properties by using the -D option, pronounced with an upper case 'D'

All you have to do i suse the -D flag, and provide the system prperty name immediately following the D, and equals sign, and then the value to be assigned to the property. For example, to set the file.encoding property of the Java runtime to utf-8, you could set the following property:

java -Dfile.encoding=utf-8

You can then grab the value programatically as follows:

System.getProperty("file.encoding"); /*this method is overloaded, as per previous post*/

System geProperty JavaDoc

Don't confuse the -D switch with the -d switch. Both are tested on the SCJA exam, but both do different things. Casing is important!

Some of the default properties that are supposed to have already been set include: file.encoding, file.separator, java.home and java.version.

转载于:https://my.oschina.net/u/138995/blog/192570

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值