欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java获得系统参数,java获得参数,package cn.o

来源: javaer 分享于  点击 23779 次 点评:13

java获得系统参数,java获得参数,package cn.o


package cn.outofmemory.snippets.core;import java.lang.management.ManagementFactory;import java.lang.management.RuntimeMXBean;import java.util.Map;import java.util.Set;public class SystemProperties {    public static void main(String[] args) {        RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();        // Create a Map that holds all the properties        Map<String, String> properties = bean.getSystemProperties();        // Take all the keys from the Map and store them to a Set of keys         Set<String> keys = properties.keySet();        // For every key obtain information        for (String key : keys) {            String value = properties.get(key);            System.out.println("Property["+ key +"] = " + value);        }    }}

输出:

Property[java.vm.version] = 21.0-b17Property[sun.jnu.encoding] = Cp1253Property[java.vendor.url] = http://java.oracle.com/Property[java.vm.info] = mixed modeProperty[user.dir] = C:\Users\javacodegeeks\workspaceEclipse\SnippetsProperty[sun.cpu.isalist] = amd64Property[java.awt.graphicsenv] = sun.awt.Win32GraphicsEnvironmentProperty[sun.os.patch.level] = Service Pack 1Property[java.io.tmpdir] = C:\Users\javacodegeeks\AppData\Local\Temp\Property[user.home] = C:\Users\javacodegeeksProperty[java.awt.printerjob] = sun.awt.windows.WPrinterJobProperty[java.version] = 1.7.0Property[file.encoding.pkg] = sun.ioProperty[java.vendor.url.bug] = http://bugreport.sun.com/bugreport/Property[file.encoding] = Cp1253Property[line.separator] = Property[sun.java.command] = com.javacodegeeks.snippets.core.SystemPropertiesProperty[java.vm.specification.vendor] = Oracle CorporationProperty[java.vm.vendor] = Oracle CorporationProperty[java.class.path] = C:\Users\javacodegeeks\workspaceEclipse\Snippets\binProperty[sun.io.unicode.encoding] = UnicodeLittleProperty[user.variant] = Property[os.arch] = amd64Property[user.name] = javacodegeeksProperty[user.language] = enProperty[java.runtime.version] = 1.7.0-b147Property[sun.desktop] = windowsProperty[sun.cpu.endian] = littleProperty[awt.toolkit] = sun.awt.windows.WToolkitProperty[sun.boot.library.path] = C:\Program Files\Java\jre7\binProperty[java.vm.name] = Java HotSpot(TM) 64-Bit Server VMProperty[java.home] = C:\Program Files\Java\jre7Property[java.endorsed.dirs] = C:\Program Files\Java\jre7\lib\endorsedProperty[sun.management.compiler] = HotSpot 64-Bit Tiered CompilersProperty[java.runtime.name] = Java(TM) SE Runtime EnvironmentProperty[user.country.format] = GRProperty[file.separator] = \Property[java.specification.vendor] = Oracle CorporationProperty[java.vm.specification.version] = 1.7Property[user.language.format] = elProperty[sun.java.launcher] = SUN_STANDARDProperty[user.timezone] = Property[os.name] = Windows 7Property[path.separator] = ;Property[java.ext.dirs] = C:\Program Files\Java\jre7\lib\ext;C:\Windows\Sun\Java\lib\extProperty[sun.arch.data.model] = 64Property[java.specification.name] = Java Platform API SpecificationProperty[os.version] = 6.1Property[user.script] = Property[user.country] = USProperty[java.class.version] = 51.0Property[java.vendor] = Oracle CorporationProperty[java.vm.specification.name] = Java Virtual Machine SpecificationProperty[java.specification.version] = 1.7
相关栏目:

用户点评