如何在 Java 中获取系统变量值? [英] How can I get System variable value in Java?

查看:27
本文介绍了如何在 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 中获取系统变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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