当前位置: 技术问答>java相关
求教:如何在Java中获得window的环境变量
来源: 互联网 发布时间:2015-07-26
本文导语: 我现在在做一个读取系统文件的东西,但是想从windows的环境变量里读取文件的路径。比如可以读取环境变量里的JAVA_HOME或者是PATH, 请指教。 | In both Java-enabled browsers and the appletviewer, appl...
我现在在做一个读取系统文件的东西,但是想从windows的环境变量里读取文件的路径。比如可以读取环境变量里的JAVA_HOME或者是PATH,
请指教。
请指教。
|
In both Java-enabled browsers and the appletviewer, applets can read these system properties by invoking System.getProperty(String key):
key meaning
____________ ______________________________
java.version Java version number
java.vendor Java vendor-specific string
java.vendor.url Java vendor URL
java.class.version Java class version number
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator (eg, "/")
path.separator Path separator (eg, ":")
line.separator Line separator
Applets are prevented from reading these system properties:
key meaning
____________ _____________________________
java.home Java installation directory
java.class.path Java classpath
user.name User account name
user.home User home directory
user.dir User's current working directory
To read a system property from within an applet, simply invoke System.getProperty(key) on the property you are interested in.
For example,
String s = System.getProperty("os.name");
key meaning
____________ ______________________________
java.version Java version number
java.vendor Java vendor-specific string
java.vendor.url Java vendor URL
java.class.version Java class version number
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator (eg, "/")
path.separator Path separator (eg, ":")
line.separator Line separator
Applets are prevented from reading these system properties:
key meaning
____________ _____________________________
java.home Java installation directory
java.class.path Java classpath
user.name User account name
user.home User home directory
user.dir User's current working directory
To read a system property from within an applet, simply invoke System.getProperty(key) on the property you are interested in.
For example,
String s = System.getProperty("os.name");
|
请问如何可以修改Windows环境变量中各种属性值呢?