java 获取系统相关属性

package com.shine;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
public class SystemInfo {
static private Properties properties;
/**
* @param args
*/
public static void main(String[] args) {
getProperties();
Hashtable<String, String> hashKey = new Hashtable<String, String>();
//将系统信息的关键字和标题放到hashtable
hashKey.put("java.home", "Java安装目录 ");
hashKey.put("java.class.path", "装载类的路径 ");
hashKey.put("java.specification.version", "Java API 规范的版本 ");
hashKey.put("java.specification.vendor", "Java API 规范的厂商 ");
hashKey.put("java.specification.name", "Java API 规范的名称 ");
hashKey.put("java.version", "Java API 实现的版本 ");
hashKey.put("java.vendor", "Java API 实现的厂商 ");
hashKey.put("java.vendor.url", "Java API 规范厂商的URL");
hashKey.put("java.vm.specification.version", "Java虚拟机规范的版本 ");
hashKey.put("java.vm.specification.vendor", "Java虚拟机规范的厂商 ");
hashKey.put("java.vm.specification.name", "Java虚拟机规范的名称 ");
hashKey.put("java.vm.version", "Java虚拟机实现的版本 ");
hashKey.put("java.vm.vendor", "Java虚拟机实现的厂商 ");
hashKey.put("java.vm.name", "Java虚拟机实现的名称 ");
hashKey.put("java.class.version", "Java类文件格式的版本 ");
hashKey.put("os.name", "主机操作系统的名称 ");
hashKey.put("os.arch", "主机操作系统的体系结构");
hashKey.put("os.version", "主机操作系统的版本 ");
hashKey.put("file.separator", "平台目录的分隔符 ");
hashKey.put("path.separator", "平台路径的分隔符 ");
hashKey.put("line.separator", "平台文本行的分隔符 ");
hashKey.put("user.name", "当前用户的帐户名称 ");
hashKey.put("user.home", "当前用户的根目录 ");
hashKey.put("user.dir", "当前工作目录 ");
hashKey.put("java.io.tmpdir", "默认临时文件路径 ");
hashKey.put("java.compiler", "JIT 编译器 ");
hashKey.put("java.ext.dirs","扩展路径");

Enumeration<String> enumer = hashKey.keys();
String propertyKey;
while (enumer.hasMoreElements()) {
propertyKey = (String) enumer.nextElement();
System.out.println((String) hashKey.get(propertyKey) + ":" +
properties.getProperty(propertyKey));
}
}
public static void getProperties() {
properties = System.getProperties();
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值