哪些是Java的源代码来填充系统属性 [英] Which are the source of java to fill system properties

查看:148
本文介绍了哪些是Java的源代码来填充系统属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 System.getProperty(String key)可以获取某些Java系统属性的值,但是我的问题是Java如何填充这些值,更确切地讲,此信息的来源在哪里.我在此处等地方查看,但我没有看到找不到答案.

Through System.getProperty(String key) you can get the value of some java system properties, however my question is about how java fill these values, more exactly where is the source of this information. I'm looking in some places like here but I didn't found an answer.

我的问题是我正在尝试测试代码的某些行为,并且我想在Java之外更改os.name值的系统属性(我知道我可以使用

My problem is that I'm trying to test some behaviours of my code, and I want to change the system property for os.name value outside of java (I know that I can set the value with System.setProperty(String key, String value) however I want to do it outside), so anybody knows what I've to change in order to get the new value through System.getProperty('os.name')?

谢谢!

推荐答案

我不认为您应该修改内置的系统属性(部分)

I don't believe you should modify the built-in System Properties, the linked Java Tutorial says (in part)

System类维护一个Properties对象,该对象描述当前工作环境的配置.

The System class maintains a Properties object that describes the configuration of the current working environment.

警告:更改系统属性有潜在危险,应谨慎执行.启动后不会重新读取许多系统属性,这些属性仅供参考.更改某些属性可能会产生意想不到的副作用.

Warning: Changing system properties is potentially dangerous and should be done with discretion. Many system properties are not reread after start-up and are there for informational purposes. Changing some properties may have unexpected side-effects.

最后

要修改现有的系统属性集,请使用System.setProperties.此方法采用一个Properties对象,该对象已初始化为包含要设置的属性.

To modify the existing set of system properties, use System.setProperties. This method takes a Properties object that has been initialized to contain the properties to be set.

这篇关于哪些是Java的源代码来填充系统属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆