How can I get System variable value in Java?(如何在 Java 中获取系统变量值?)
问题描述
我怎样才能得到系统变量的值是存在于
How can I get the System Variable value which is present in
MyComputer -> Properties -> Advanced -> Environment Variables -> System Variables
在 Java 中?
编辑
我用过System.getenv()方法.
如果给的话就是印刷价值
It is printing value if I give
System.out.println(System.getenv("JAVA_HOME"));
如果我为我创建的系统变量尝试相同的值,它会显示 null 值
and it is showing null value if I try the same for system variable created by me
System.out.println(System.getenv("DBE"));
推荐答案
使用System.getenv(String) 方法,传入要读取的变量名.
Use the System.getenv(String) method, passing the name of the variable to read.
这篇关于如何在 Java 中获取系统变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Java 中获取系统变量值?
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
