【问题标题】:System.getProperty() showing nullSystem.getProperty() 显示为空
【发布时间】:2020-06-19 05:44:22
【问题描述】:

如何在 java 中获取系统属性的默认值,例如 ntlm.debug 或 jdk.tls.stapling。忽略扩展 在使用 system.getProperty(Property name) 时给出 null。我正在运行 jdk 版本 11.0.7 有没有其他方法可以获取属性的默认值?

【问题讨论】:

  • 请提供minimal reproducible example。另外你是如何运行你的程序的?从命令行或在 IDE(如 Eclipse、Netbeans、IntelliJ 等)中
  • import java.util.Properties; public class ListSystemProperties { public static void main(String[] args) { System.out.println(System.getProperty("jdk.tls.stapling.ignoreExtensions")); } } 这是我正在使用和从命令行运行的基本代码

标签: java system-properties


【解决方案1】:
System.getProperties() will give a map of all default properties of the system.
like
sun.management.compiler : HotSpot 64-Bit Tiered Compilers
sun.jnu.encoding : UTF-8
java.runtime.version : 14+36-1461
...

【讨论】:

  • 谢谢,所以这里没有列出的不是默认的,需要明确指定?
  • 是的,System.getProperties().put("hello", "hello");
猜你喜欢
  • 1970-01-01
  • 2019-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-14
  • 2013-10-03
相关资源
最近更新 更多