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

查看:134
本文介绍了如何在Java中获取系统变量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取

MyComputer - >属性 - >高级 - >环境变量 - >系统变量

在Java?

编辑

我使用了 System.getenv()方法。

正在打印值if我给

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() 方法,将变量的名称传递给读取。

Use the System.getenv() method, passing the name of the variable to read.

这篇关于如何在Java中获取系统变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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