sysprops.js

来自「一个小公司要求给写的很简单的任务管理系统。」· JavaScript 代码 · 共 49 行

JS
49
字号
/* * This file defines 'sysprops' function to print Java System * properties.'sysprops' function which can be called once or periodically  * from a timer thread (calling it periodically would slow down the target * application). To call this once, just call 'sysprops()' in script * console prompt. To call jtop in a timer thread, you can use * *     var t = setTimeout(function () { sysprops(print); }, 5000);  * * The above call prints threads in sorted order for every 5 seconds. * The print output goes to OS console window from which jconsole was  * started. The timer can be cancelled later by clearTimeout() function * as shown below: *  *     clearTimeout(t);     *//** * Returns System properties as a Map */function getSystemProps() {    var runtimeBean = newPlatformMXBeanProxy(                "java.lang:type=Runtime",                java.lang.management.RuntimeMXBean);    return runtimeBean.systemProperties;}/** * print System properties * * @param printFunc function called to print [optional] */function sysprops(printFunc) {    // by default use 'echo' to print. Other choices could be    // 'print' or custom function that writes in a text file    if (printFunc == undefined) {        printFunc = echo;    }    var map = getSystemProps();    var keys = map.keySet().iterator();    while (keys.hasNext()) {        var key = keys.next();        var value = map.get(key);        printFunc(key + "=" + value);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?