- 浏览: 460673 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
ty1972873004:
sunwang810812 写道我运行了这个例子,怎么结果是这 ...
Java并发编程: 使用Semaphore限制资源并发访问的线程数 -
lgh1992314:
simpleDean 写道请问,Logger.setLevel ...
Java内置Logger详解 -
sunwang810812:
我运行了这个例子,怎么结果是这样的:2号车泊车6号车泊车5号车 ...
Java并发编程: 使用Semaphore限制资源并发访问的线程数 -
jp260715007:
nanjiwubing123 写道参考你的用法,用如下方式实现 ...
面试题--三个线程循环打印ABC10次的几种解决方法 -
cb_0312:
SurnameDictionary文章我没看完,现在懂了
中文排序
我们可以通过如下两种方式获取System Properties信息:
1. System.getProperties()
2. ManagementFactory.getRuntimeMXBean().getSystemProperties()
ManagementFactory.getRuntimeMXBean().getSystemProperties方法采用System.getProperties()来完成的,如果在本地运行程序去获取某些系统属性的值,结果是一样的。
它们的一个区别,RuntimeMXBean能够去获取远程 VM上的System Properties。
ManagementFactory的newPlatformMXBeanProxy方法提供了访问远程VM的方法。可采取如下方式来访问远程VM,参考https://blogs.oracle.com/jmxetc/entry/how_to_retrieve_remote_jvm
// Connect to target final JMXConnector connector = JMXConnectorFactory.connect(target); // Get an MBeanServerConnection on the remote VM. final MBeanServerConnection remote = connector.getMBeanServerConnection(); final RuntimeMXBean remoteRuntime = ManagementFactory.newPlatformMXBeanProxy( remote, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
RuntimeMXBean的具体内容如下:
/* * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ package sun.management; import java.lang.management.RuntimeMXBean; import java.util.List; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Properties; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataSupport; import javax.management.openmbean.CompositeType; import javax.management.openmbean.OpenType; import javax.management.openmbean.SimpleType; import javax.management.openmbean.OpenDataException; /** * Implementation class for the runtime subsystem. * Standard and committed hotspot-specific metrics if any. * * ManagementFactory.getRuntimeMXBean() returns an instance * of this class. */ class RuntimeImpl implements RuntimeMXBean { private final VMManagement jvm; private final long vmStartupTime; /** * Constructor of RuntimeImpl class. */ RuntimeImpl(VMManagement vm) { this.jvm = vm; this.vmStartupTime = jvm.getStartupTime(); } public String getName() { return jvm.getVmId(); } public String getManagementSpecVersion() { return jvm.getManagementVersion(); } public String getVmName() { return jvm.getVmName(); } public String getVmVendor() { return jvm.getVmVendor(); } public String getVmVersion() { return jvm.getVmVersion(); } public String getSpecName() { return jvm.getVmSpecName(); } public String getSpecVendor() { return jvm.getVmSpecVendor(); } public String getSpecVersion() { return jvm.getVmSpecVersion(); } public String getClassPath() { return jvm.getClassPath(); } public String getLibraryPath() { return jvm.getLibraryPath(); } public String getBootClassPath() { if (!isBootClassPathSupported()) { throw new UnsupportedOperationException( "Boot class path mechanism is not supported"); } ManagementFactory.checkMonitorAccess(); return jvm.getBootClassPath(); } public List<String> getInputArguments() { ManagementFactory.checkMonitorAccess(); return jvm.getVmArguments(); } public long getUptime() { long current = System.currentTimeMillis(); // TODO: If called from client side when we support // MBean proxy to read performance counters from shared memory, // need to check if the monitored VM exitd. return (current - vmStartupTime); } public long getStartTime() { return vmStartupTime; } public boolean isBootClassPathSupported() { return jvm.isBootClassPathSupported(); } public Map<String,String> getSystemProperties() { Properties sysProps = System.getProperties(); Map<String,String> map = new HashMap<String, String>(); // Properties.entrySet() does not include the entries in // the default properties. So use Properties.stringPropertyNames() // to get the list of property keys including the default ones. Set<String> keys = sysProps.stringPropertyNames(); for (String k : keys) { String value = sysProps.getProperty(k); map.put(k, value); } return map; } }
如果博友知道两者的其它区别,也请指出,谢谢。
发表评论
-
工厂类中移除if/else语句
2016-07-10 19:52 857面向对象语言的一个强大的特性是多态,它可以用来在代码中移除 ... -
Java编程练手100题
2014-12-11 17:13 6675本文给出100道Java编程练手的程序。 列表如下: 面 ... -
数组复制的三种方法
2014-11-30 12:57 2182本文将给出三种实现数组复制的方法 (以复制整数数组为例)。 ... -
数组复制的三种方法
2014-11-30 12:54 0本文将给出三种实现数组复制的方法 (以复制整数数组为例)。 ... -
四种复制文件的方法
2014-11-29 13:21 1691尽管Java提供了一个类ava.io.File用于文件的操 ... -
判断一个字符串中的字符是否都只出现一次
2014-11-25 12:58 2663本篇博文将给大家带来几个判断一个字符串中的字符是否都只出现一 ... -
使用正则表达式判断一个数是否为素数
2014-11-23 13:35 2108正则表达式能够用于判断一个数是否为素数,这个以前完全没有想过 ... -
几个可以用英文单词表达的正则表达式
2014-11-21 13:12 3707本文,我们将来看一下几个可以用英文单词表达的正则表达式。这些 ... -
(广度优先搜索)打印所有可能的括号组合
2014-11-20 11:58 1926问题:给定一个正整n,作为括号的对数,输出所有括号可能 ... -
随机产生由特殊字符,大小写字母以及数字组成的字符串,且每种字符都至少出现一次
2014-11-19 14:48 3946题目:随机产生字符串,字符串中的字符只能由特殊字符 (! ... -
找出1到n缺失的一个数
2014-11-18 12:57 3121题目:Problem description: You h ... -
EnumSet的几个例子
2014-11-14 16:24 8712EnumSet 是一个与枚举类型一起使用的专用 Set 实现 ... -
给定两个有序数组和一个指定的sum值,从两个数组中各找一个数使得这两个数的和与指定的sum值相差最小
2014-11-12 11:24 3288题目:给定两个有序数组和一个指定的sum值,从两个数组 ... -
Java面试编程题练手
2014-11-04 22:49 6661面试编程 写一个程序,去除有序数组中的重复数字 编 ... -
Collections用法整理
2014-10-22 20:55 9805Collections (java.util.Collect ... -
The Code Sample 代码实例 个人博客开通
2014-09-04 18:48 1379个人博客小站开通 http://thecodesample. ... -
Collections.emptyXXX方法
2014-06-08 13:37 2107从JDK 1.5开始, Collections集合工具类中预先 ... -
这代码怎么就打印出"hello world"了呢?
2014-06-08 00:37 7360for (long l = 4946144450195624L ... -
最短时间过桥
2014-04-21 22:03 4078本文用代码实现最短时间过桥,并且打印如下两个例子的最小过桥时间 ... -
将数组分割成差值最小的子集
2014-04-20 22:34 2845本文使用位掩码实现一个功能 ==》将数组分割成差值最小的子集 ...
相关推荐
获取Android手机或平板当前系统版本号、型号、厂商、唯一识别号(imei或meid)等
获取U盘ID序列号 VS2005编译通过,源码源自CSDN。已经测试好用。 可以获得U盘名称,制造商ID号 版本号 U盘序列号及容量 Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; ...
非系统应用通过两种方式获取系统SystemProperity的属性。Java层和Native层
这是获取硬件信息的 Delphi 第三方控件包,非常强大。 官方在2013年7月24日更新的版本,试用版在软件运行时会弹出控件版权信息框。破解MSI_Common.dcu后,无信息框弹出! 控件详细说明: Product: MiTeC System ...
下面是通过 adb shell cat /system/build.prop 获取到的信息 # begin build properties开始设置系统性能 # autogenerated by buildinfo.sh{通过设置形成系统信息} ro.build.id=MIUI(版本ID) ro.build.display.id=...
银行系统 银行系统是一个简单的C ++程序,在典型的银行系统中具有3种类型的用户:客户,经理,维护人员 此应用程序是为Western的面向对象设计课程开发的。... 获取银行帐户统计信息(最大,最小,平均
本文实例讲述了C#编程获取客户端计算机硬件及系统信息功能。分享给大家供大家参考,具体如下: 这里使用C#获取客户端计算机硬件及系统信息 ,包括CPU、硬盘、IP、MAC地址、操作系统等。 1、项目引用System....
*这里是我的参数放在了properties文件中,我在读取里面的参数,这里我们也可以通过方法传参数 *如 : testWebService(String url,String xMlStr)() 那么在调用的时候就可以直接传进来了 *url 是你访问的webservice 的...
System.out.println("读取配置文件/config.properties出错"); } } /** * 程序总入口 */ private void start() { for(int i = 0; i (); i++) { URLConnection con = getConnection(configList.get(i)); ...
System.Data.DataTable sTable = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null); string sheetName = string.Empty; List<string> siteCodes = new List(); string ...
二、JDBC接口 所属包:java.sql Javax.sql ... //调用数据库连接方法,获取数据库连接 Connection conn = driver.connect(url, pro); System.out.println(conn); //关闭数据库连接 conn.close(); }
你可能知道在WinForm应用程序中可以利用Properties.Settings来进行类似的工作,但这些其实都利用了App.config配置文件。 本文探讨用代码的方式访问 App.config 的方法。关于 App.config 的使用远比上面提到的用途...
再简单介绍一下名称空间(NameSpace)System.Web.Mail类库里所提供的邮件发送的对象、属性和方法 (1)它有三个类:SmtpMail、MailMessage和MailAttachment。这三个对象本文的示例程序代码中都应用到了! 1. ...
//--获取ccc 结点的 attributes 值 Map obj3 = (Map)cb.getRoot().getValueByPath("servers.dbserver.ccc:$properties"); //--获取dbserver 结点的 孩子结点表 List<ConfigNode> ...
获取设备标识符 发送消息(日志、通知) 监听传感器 先决条件 JDK(通用) 设置JAVA_HOME环境。 变量是必不可少的 Gradle(普通) 设置GRADLE_HOME环境。 变量是必不可少的 Adobe AIR SDK (Flash) 设置AIR_HOME...
零件编号管理系统 这是为美国仓库实施的基于Web的零件编号... 请查看\ src \ main \ resources \ application.properties 根据您的LDAP服务器更新LDAP身份验证设置。 请查看\ src \ main \ resources \ global.propert
redirect就是服务端根据逻辑,发送一个状态码,告诉浏览器重新去请求那个地址,一般来说浏览器会用刚才请求的所有参数重新请求,所以session,request参数都可以获取。 23、EJB与JAVA BEAN的区别? Java Bean 是可...
Druid是阿里巴巴开源平台上一个数据库连接池实现,它结合了C3P0、DBCP、Proxool等DB池的优点,同时加入了日志监控,可以很好的监控DB池连接和SQL... //测试获取超过最大连接数的连接数量(连接关闭、未关闭的情况) }
system * @author $!author * @version $!version * @date $!dateTool.format('yyyy-MM-dd', ${date}) */ public class $!{tableAlias}{ #foreach($item in $columnList) private $!item.data_type $!item....